home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_gen / euphor14.zip / LIBRARY.DOC < prev    next >
Text File  |  1996-07-11  |  97KB  |  2,572 lines

  1.  
  2.             Part II - Library Routines
  3.  
  4.  1. Introduction
  5.  
  6.  A large number of library routines are provided. Some are built right into
  7.  the interpreter, ex.exe. Others are written in Euphoria and you must include
  8.  one of the .e files in euphoria\include to use them. Where this is the case, 
  9.  the appropriate include file is noted in the "Syntax" part of the description.
  10.  Of course an include file need only be included once in your program. The 
  11.  editor displays in magenta those routines that are built into the interpreter,
  12.  ex.exe, and require no include file. You can override the definition of these
  13.  built-in routines by defining your own routine with the same name. You will 
  14.  get a suppressible warning if you do this.
  15.  
  16.  To indicate what kind of object may be passed in and returned, the following 
  17.  prefixes are used:
  18.  
  19.    x - a general object (atom or sequence)
  20.    s - a sequence
  21.    a - an atom
  22.    i - an integer 
  23.   fn - an integer used as a file number
  24.   st - a string sequence, or single-character atom
  25.  
  26.  An error will result if an illegal argument value is passed to any of these 
  27.  routines.
  28.  
  29.  
  30.  2. Routines by Application Area
  31.  
  32.  2.1  Predefined Types         
  33.       
  34.       As well as declaring variables with these types, you can also call them 
  35.       just like ordinary functions, in order to test if a value is a certain 
  36.       type.
  37.  
  38.       integer     - test if an object is an integer
  39.       atom        - test if an object is an atom 
  40.       sequence     - test if an object is a sequence
  41.       
  42.  2.2  Sequence Manipulation   
  43.     
  44.       length     - return the length of a sequence
  45.       repeat     - repeat an object n times to form a sequence of length n
  46.       append     - add a new element to the end of a sequence
  47.       prepend     - add a new element to the beginning of a sequence
  48.       
  49.  2.3  Searching and Sorting  
  50.  
  51.       compare     - compare two objects
  52.       find        - find an object in a sequence
  53.       match       - find a sequence as a slice of another sequence
  54.       sort        - sort the elements of a sequence into ascending order
  55.  
  56.  2.4  Pattern Matching
  57.       
  58.       lower     - convert a string to lower case
  59.       upper     - convert a string to upper case
  60.       wildcard_match - match a pattern containing ? and * wildcards
  61.       wildcard_file  - match a file name against a wild card specification
  62.  
  63.  2.5  Math            
  64.  
  65.       These routines can be applied to individual atoms or to sequences of 
  66.       values. See "Arithmetic Operations on Sequences" in chapter 2 of the
  67.       reference manual.
  68.       
  69.       sqrt    - calculate the square root of an object
  70.       rand    - generate random numbers
  71.       sin    - calculate the sine of an angle
  72.       cos    - calculate the cosine of an angle
  73.       tan    - calculate the tangent of an angle
  74.       log    - calculate the natural logarithm 
  75.       floor    - round down to the nearest integer
  76.       remainder    - calculate the remainder when a number is divided by another
  77.       power    - calculate a number raised to a power
  78.  
  79.  
  80.  2.6  File and Device I/O 
  81.  
  82.       To do input or output on a file or device you must first open the file
  83.       or device, then use the routines below to read or write to it, then close 
  84.       the file or device. open() will give you a file number to use as the 
  85.       first argument of the other I/O routines. Certain files/devices are 
  86.       opened for you automatically (as text files):
  87.  
  88.          0 - standard input
  89.          1 - standard output
  90.          2 - standard error
  91.  
  92.       Unless you redirect them on the command line, standard input comes from 
  93.       the keyboard, standard output and standard error go to the screen. When 
  94.       you write something to the screen it is written immediately without 
  95.       buffering. If you write to a file, your characters are put into a buffer 
  96.       until there are enough of them to write out efficiently. When you close 
  97.       the file or device, any remaining characters are written out. Input from
  98.       files is also buffered. When your program terminates, any files that are
  99.       still open will be closed for you automatically.
  100.       
  101.       Note: If a program (written in Euphoria or any other language) has a 
  102.       file open for writing, and you are forced to reboot your computer for 
  103.       any reason, you should immediately run CHKDSK or SCANDISK to repair any 
  104.       damage to the file system that may have occurred.
  105.  
  106.       open    - open a file or device
  107.       close    - close a file or device
  108.       print    - print a Euphoria object with {,,} to show the structure
  109.       ? x    - shorthand for print(1, x)
  110.       printf    - formatted print to a file or device
  111.       sprintf   - formatted print returned as a string sequence
  112.       puts    - output a string sequence to a file or device
  113.       getc    - read the next character from a file or device
  114.       gets    - read the next line from a file or device
  115.       get_key    - check for key pressed by the user, don't wait
  116.       wait_key  - wait for user to press a key
  117.       get    - read the representation of any Euphoria object from a file
  118.       value    - read the representation of any Euphoria object from a string
  119.       seek    - move to any character position within an open file
  120.       where    - report the current character position in an open file
  121.       current_dir - return the name of the current directory
  122.       dir    - return complete info on all files in a directory
  123.       
  124.  2.7  Mouse Support   
  125.  
  126.       get_mouse        - return mouse "events" (clicks, movements)
  127.       mouse_events  - select mouse events to watch for
  128.       mouse_pointer - display or hide the mouse pointer
  129.  
  130.  2.8  Operating System 
  131.  
  132.       time    - number of seconds since a fixed point in the past
  133.       date    - current year, month, day, hour, minute, second etc.
  134.       command_line - DOS command-line used to run this program
  135.       getenv    - get value of an environment variable
  136.       system    - execute a DOS command line
  137.       abort    - terminate execution
  138.       
  139.  2.9 Special Machine-dependent routines
  140.       
  141.       machine_func - specialized operations in ex.exe with return value
  142.       machine_proc - specialized operations in ex.exe - no return value
  143.       
  144.  2.10 Debugging
  145.  
  146.       trace    - dynamically turns tracing on or off
  147.  
  148.  2.11 Graphics & Sound
  149.   
  150.       clear_screen - clear the screen - text or graphics
  151.       position       - set cursor line and column
  152.       get_position - return cursor line and column
  153.       graphics_mode - select a new graphics (or text) mode
  154.       video_config - return parameters of current graphics mode
  155.       scroll       - scroll text screen up or down
  156.       wrap       - control line wrap at right edge of screen
  157.       cursor       - select cursor shape
  158.       text_color   - set foreground text color
  159.       bk_color       - set background color for text and graphics
  160.       palette       - change color for one color number
  161.       all_palette  - change color for all color numbers
  162.       text_rows       - set number of lines on text screen
  163.       pixel       - set color of a pixel or set of pixels
  164.       get_pixel       - read color of a pixel or set of pixels
  165.       draw_line    - connect a series of graphics points with a line
  166.       polygon       - draw an n-sided figure
  167.       ellipse       - draw an ellipse (circle)
  168.       sound       - make a sound on the PC speaker
  169.       read_bitmap  - read a bitmap file and return a sequence of pixels
  170.       save_image   - save a rectangular region from a graphics screen
  171.       save_text_image - save a rectangular region from a text screen
  172.       display_image - display an image on the graphics screen
  173.       display_text_image - display an image on the text screen
  174.       get_active_page - return the page currently being written to
  175.       set_active_page - change the page currently being written to    
  176.       get_display_page - return the page currently being displayed
  177.       set_display_page - change the page currently being displayed
  178.  
  179.  2.12 Machine Level Interface 
  180.  
  181.       With this low-level machine interface you can read and write to memory.
  182.       You can also set up your own 386+ machine language routines and call 
  183.       them. The usual guarantee that Euphoria will protect you from machine-
  184.       level errors does *not* apply when you use these routines. If you happen
  185.       to reference a bad address, it will likely be caught by the Causeway DOS
  186.       extender and you'll see an error message on the screen plus a dump of
  187.       machine-level information in the file CW.ERR.
  188.  
  189.       Most Euphoria programmers will never use this interface, but it is 
  190.       important because it makes it possible to get into every nook and cranny  
  191.       of the hardware and operating system. For those with very specialized
  192.       applications this could be crucial. 
  193.  
  194.       Machine code routines can be written by hand, or taken from the 
  195.       disassembled output of a compiler for C or some other language. 
  196.       Remember that your machine code will be running in 32-bit protected 
  197.       mode. See demo\callmach.ex for an example.
  198.  
  199.       peek         - read one or more bytes from memory
  200.       poke        - write one or more bytes to memory
  201.       call        - call a machine language routine
  202.       dos_interrupt - call a DOS software interrupt routine
  203.       allocate        - allocate a block of memory
  204.       free        - deallocate a block of memory
  205.       allocate_low  - allocate a block of low memory (address less than 1Mb)
  206.       free_low        - free a block allocated with allocate_low
  207.       int_to_bytes  - convert an integer to 4 bytes
  208.       bytes_to_int  - convert 4 bytes to an integer
  209.       int_to_bits   - convert an integer to a sequence of bits
  210.       bits_to_int   - convert a sequence of bits to an integer
  211.       set_rand        - set the random number generator so it will generate
  212.                     a repeatable series of random numbers
  213.       use_vesa      - force the use of the VESA graphics standard
  214.       crash_message - specify a message to be printed if Euphoria detects an
  215.                     an error in your program
  216.                     
  217.      
  218.  3. Alphabetical Listing of all Routines
  219.              
  220.              
  221.  
  222. ──────────────────────────────────────<?>───────────────────────────────────────
  223.  
  224.  Syntax:      ? x    
  225.  
  226.  Description: This is just a shorthand way of saying:  print(1, x)
  227.            i.e. printing the value of an expression to the standard output. 
  228.           
  229.  Example: 
  230.           ? {1, 2} + {3, 4}  
  231.           
  232.           would display {4, 6}. 
  233.  
  234.  Comments:    ? differs slightly from print() since it will add new-lines to 
  235.            make the output more readable on your screen or wherever you 
  236.            have directed standard output.  
  237.  
  238.  See Also:    print
  239.  
  240. ────────────────────────────────────<abort>─────────────────────────────────────
  241.  
  242.  Syntax:      abort(a)       
  243.     
  244.  Description: Abort execution of the program. The argument a is an integer 
  245.            status value to be returned to the operating system. A value of 0
  246.            generally indicates successful completion of the program. Other 
  247.            values can indicate various kinds of errors. DOS batch (.bat)
  248.            programs can read this value using the errorlevel feature.
  249.            
  250.  Comments:    abort() is useful when a program is many levels deep in 
  251.            subroutine calls, and execution must end immediately, perhaps
  252.            due to a severe error that has been detected.
  253.  
  254.           Normally ex.exe returns an exit status code of 0. If your program
  255.           fails with a Euphoria-detected compile-time or run-time error
  256.           then a code of 1 is returned.
  257.           
  258.  Example:     
  259.            if x = 0 then
  260.                puts(ERR, "can't divide by 0 !!!\n")
  261.                abort(1)
  262.            else
  263.                z = y / x
  264.            end if
  265.  
  266.  See Also:    crash_message
  267.  
  268. ─────────────────────────────────<all_palette>──────────────────────────────────
  269.  
  270.  Syntax:      include graphics.e
  271.           all_palette(s)
  272.       
  273.  Description: Specify new color intensities for the entire set of colors in the
  274.            current graphics mode. s is a sequence of the form:
  275.                
  276.                {{r,g,b}, {r,g,b}, ... {r,g,b}}
  277.            
  278.            Each element specifies a new color intensity {red, green, blue}
  279.            for the corresponding color number, starting with color number 0.
  280.           The values for red, green and blue must be in the range 0 to 63.
  281.           
  282.  Comments:    This executes much faster than if you were to use palette() to 
  283.            set the new color intensities one by one. This procedure can
  284.            be used with read_bitmap() to quickly display a picture on the
  285.            screen.
  286.            
  287.  Example Program: demo\bitmap.ex
  288.  
  289.  See Also:    palette, read_bitmap, video_config, graphics_mode           
  290.            
  291. ───────────────────────────────────<allocate>───────────────────────────────────
  292.  
  293.  Syntax:      include machine.e
  294.            a = allocate(i)
  295.     
  296.  Description: Allocate i contiguous bytes of memory. Return the address of the
  297.           block of memory, or return 0 if the memory can't be allocated.
  298.           
  299.  Example:     buffer = allocate(100)
  300.            for i = 0 to 99 do
  301.                  poke(buffer+i, 0)
  302.            end for
  303.  
  304.  See Also:    free, allocate_low, peek, poke, call
  305.  
  306. ─────────────────────────────────<allocate_low>─────────────────────────────────
  307.  
  308.  Syntax:      include machine.e
  309.            i2 = allocate_low(i1)
  310.     
  311.  Description: Allocate i1 contiguous bytes of low memory, i.e. conventional
  312.             memory with an address below 1 megabyte. Return the address 
  313.            of the block of memory, or return 0 if the memory can't be 
  314.            allocated. 
  315.            
  316.  Comment:     Some DOS software interrupts require that you pass one or
  317.            more addresses in registers. These addresses must be 
  318.            conventional memory addresses for DOS to be able to read or 
  319.            write to them.
  320.           
  321.  Example Program: demo\dosint.ex
  322.  
  323.  See Also:    dos_interrupt, free_low, allocate, peek, poke
  324.  
  325. ────────────────────────────────────<append>────────────────────────────────────
  326.  
  327.  Syntax:      s2 = append(s1, x)
  328.     
  329.  Description: Create a new sequence identical to s1 but with x added on the end
  330.            as the last element. The length of s2 will be length(s1) + 1. 
  331.           
  332.  Comments:    If x is an atom this is equivalent to s2 = s1 & x. If x is a 
  333.            sequence it is not equivalent. 
  334.           
  335.           The extra storage is allocated automatically and very 
  336.           efficiently with Euphoria's dynamic storage allocation. 
  337.           The case where s1 and s2 are actually the same variable 
  338.           (as in Example 1 below) is highly optimized.
  339.           
  340.  Example 1:   You can use append to dynamically grow a sequence, e.g.
  341.     
  342.           sequence x
  343.           
  344.           x = {}
  345.           for i = 1 to 10 do
  346.           x = append(x, i)
  347.           end for
  348.           -- x is now {1,2,3,4,5,6,7,8,9,10}
  349.  
  350.  Example 2:   Any kind of Euphoria object can be appended to a sequence, e.g
  351.            
  352.            sequence x, y, z
  353.            
  354.            x = {"fred", "barney"}
  355.            y = append(x, "wilma")
  356.            -- y is now {"fred", "barney", "wilma"}
  357.     
  358.           z = append(append(y, "betty"), {"bam", "bam"})
  359.           -- z is now {"fred", "barney", "wilma", "betty", {"bam", "bam"}}
  360.           
  361.  See Also:    prepend, concatenation (&) and sequence-formation {,,} operators 
  362.            in refman.doc
  363.  
  364. ─────────────────────────────────────<atom>─────────────────────────────────────
  365.  
  366.  Syntax:      i = atom(x)
  367.     
  368.  Description: Return 1 if x is an atom else return 0.
  369.  
  370.  Comments:    This serves to define the atom type. You can also call it
  371.           like an ordinary function to determine if an object is an
  372.           atom.
  373.          
  374.  Example 1:
  375.            atom a
  376.            a = 5.99
  377.            
  378.  Example 2:
  379.            line = gets(0)
  380.            if atom(line) then
  381.                 puts(SCREEN, "end of file\n")
  382.            end if
  383.           
  384.  See Also:    sequence
  385.  
  386. ─────────────────────────────────<bits_to_int>──────────────────────────────────
  387.  
  388.  Syntax:      include machine.e
  389.            a = bits_to_int(s)
  390.            
  391.  Description: Convert a sequence of binary 1's and 0's into a positive
  392.             number. The least-significant bit is s[1].
  393.             
  394.  Comments:    If you print s the bits will appear in "reverse" order, but
  395.            it is convenient to have increasing subscripts access bits of 
  396.            increasing significance.
  397.            
  398.  Example:     a = bits_to_int({1,1,1,0,1})
  399.            -- a is 23 (binary 10111)
  400.  
  401.  See Also:    int_to_bits, and/or/not of sequences in refman.doc
  402.             
  403. ───────────────────────────────────<bk_color>───────────────────────────────────
  404.  
  405.  Syntax:      include graphics.e 
  406.            bk_color(i)
  407.     
  408.  Description: Set the background color. In graphics modes the whole screen is
  409.           affected immediately. In text modes any new characters that you 
  410.           print will have the new background color.
  411.  
  412.  Comments:    The various colors are defined as constants in graphics.e
  413.  
  414.            To restore the original background color when your program 
  415.            finishes, e.g. 0 - BLACK, you must call bk_color(0), and then if 
  416.            you are at the bottom line of the screen, ready to scroll up, 
  417.            you may have to actually print something before terminating your 
  418.            program. Printing '\n' may be enough. 
  419.            
  420.  Example:     bk_color(BLACK)
  421.  
  422.  See Also:    text_color
  423.  
  424. ─────────────────────────────────<bytes_to_int>─────────────────────────────────
  425.  
  426.  Syntax:      include machine.e
  427.            a = bytes_to_int(s)
  428.            
  429.  Description: Convert a 4-element sequence of byte values to an atom.
  430.             The elements of s are in the order expected for a 32-bit
  431.             integer on the 386, i.e. least significant byte first. 
  432.  
  433.  Comments:    The result could be greater than the integer type allows,
  434.              so you should assign it to an atom.
  435.  
  436.             s would normally contain positive values that have been read 
  437.             using peek() from 4 consecutive memory locations. 
  438.              
  439.  Example:     atom int32
  440.            
  441.            int32 = bytes_to_int({37,1,0,0})
  442.            -- int32 is 37 + 256*1 = 293 
  443.  
  444.  See Also:    int_to_bytes, bits_to_int, peek, poke
  445.  
  446. ─────────────────────────────────────<call>─────────────────────────────────────
  447.  
  448.  Syntax:      call(a)
  449.     
  450.  Description: Call a machine language routine that starts at address a. This
  451.           routine must execute a RET instruction #C3 to return control
  452.           to Euphoria. The routine should save and restore any registers 
  453.           that it uses. 
  454.           
  455.  Comments:    You can allocate a block of memory for the routine and then poke
  456.             in the bytes of machine code. You might allocate other blocks of
  457.             memory for data and parameters that the machine code can operate
  458.             on. The addresses of these blocks could be poked into the 
  459.             machine code. 
  460.  
  461.  Example Program: see demo\callmach.ex
  462.  
  463.  See Also:    allocate, free, peek, poke
  464.  
  465. ─────────────────────────────────<clear_screen>─────────────────────────────────
  466.  
  467.  Syntax:      clear_screen()
  468.     
  469.  Description: Clear the screen using the current background color (may be set 
  470.            by bk_color()). 
  471.  
  472.  Comments:    This works in all text and graphics modes.
  473.  
  474.  See Also:    bk_color, graphics_mode
  475.  
  476. ────────────────────────────────────<close>─────────────────────────────────────
  477.  
  478.  Syntax:      close(fn)
  479.     
  480.  Description: Close a file or device and flush out any still-buffered 
  481.            characters.
  482.  
  483.  Comments:    Any still-open files will be closed automatically when your 
  484.            program terminates.
  485.            
  486.  See Also:    open
  487.  
  488. ────────────────────────────────<command_line>──────────────────────────────────
  489.  
  490.  Syntax:      s = command_line() 
  491.  
  492.  Description: Return a sequence of strings, where each string is a word from 
  493.            the command line that started your program. The first word will
  494.            be the path to either the Euphoria executable, ex.exe or to
  495.            your bound .exe file. The next word is either the name of your 
  496.            Euphoria .ex file, or the path to your bound .exe file. After 
  497.            that will come any extra words typed by the user. You can use 
  498.            these words in your program. 
  499.  
  500.  Comments:    Euphoria (ex.exe) does not use any command line options. You
  501.            are free to use any options for your own program.
  502.  
  503.            If you bind your program you will find that all command line
  504.            arguments remain the same, except for the first two, even
  505.            though your user no longer types "ex".
  506.            
  507.  Example 1:   -- The user types:  ex myprog myfile.dat 12345
  508.            
  509.            cmd = command_line()
  510.            
  511.            -- cmd will be:  {"C:\EUPHORIA\BIN\EX.EXE", 
  512.                        "myprog",
  513.                        "myfile.dat",
  514.                        "12345"}
  515.  
  516.  Example 2:   -- Your program is bound with the name "myprog.exe"
  517.            -- and is stored in the directory c:\myfiles
  518.            -- The user types:  myprog myfile.dat 12345
  519.            
  520.            cmd = command_line()
  521.            
  522.            -- cmd will be:  {"C:\MYFILES\MYPROG.EXE",
  523.                        "C:\MYFILES\MYPROG.EXE", -- spacer
  524.                        "myfile.dat",
  525.                        "12345"}
  526.           
  527.           -- Note that all arguments remain the same as Example 1 
  528.           -- except for the first two. The second argument is always
  529.           -- the same as the first and is inserted to keep the numbering
  530.           -- of the subsequent arguments the same, whether your program
  531.           -- is bound as a .exe or not.
  532.           
  533.  See Also:    getenv
  534.  
  535. ───────────────────────────────────<compare>────────────────────────────────────
  536.  
  537.  Syntax:      i = compare(x1, x2)
  538.     
  539.  Description: Return 0 if objects x1 and x2 are identical, 1 if x1 is greater 
  540.           than x2, -1 if x1 is less than x2. Atoms are considered to be 
  541.           less than sequences. Sequences are compared "alphabetically" 
  542.           starting with the first element until a difference is found. 
  543.           
  544.  Example 1:   x = compare({1,2,{3,{4}},5}, {2-1,1+1,{3,{4}},6-1})
  545.            -- identical, x is 0
  546.                
  547.  Example 2:   if compare("ABC", "ABCD") < 0 then   -- -1
  548.          -- will be true: ABC is "less" because it is shorter
  549.            end if
  550.  
  551.  See Also:    equals (=) operator in refman.doc
  552.  
  553. ─────────────────────────────────────<cos>──────────────────────────────────────
  554.  
  555.  Syntax:      x2 = cos(x1)
  556.     
  557.  Description: Return the cosine of x1, where x1 is in radians.
  558.  
  559.  Comments:    This function may be applied to an atom or to all elements
  560.            of a sequence.
  561.  
  562.  Example:     x = cos({.5, .6, .7})
  563.            
  564.            -- x is {0.8775826, 0.8253356, 0.7648422}
  565.  
  566.  See Also:    sin, tan, log, sqrt
  567.  
  568. ────────────────────────────────<crash_message>─────────────────────────────────
  569.  
  570.  Syntax:      include machine.e
  571.            crash_message(s)
  572.  
  573.  Description: Specify a string, s, to be printed on the screen in the event
  574.            that Euphoria must stop your program due to a compile-time or
  575.            run-time error. 
  576.  
  577.  Comments:    Normally Euphoria prints a diagnostic message such as 
  578.            "syntax error" or "divide by zero" on the screen, as well as 
  579.            dumping debugging information into "ex.err". Euphoria's error 
  580.            messages will not be meaningful for your users unless they
  581.            happen to be Euphoria programmers. By calling crash_message()
  582.            you can control the message that will appear on the screen.
  583.            Debugging information will still be stored in ex.err. You won't
  584.            lose any information by doing this.
  585.            
  586.            s may contain '\n', new-line characters so your message can
  587.            span several lines on the screen.
  588.            
  589.            You can call crash_message() as many times as you like from
  590.            different parts of your program. The message specified by the
  591.            last call will be the one displayed.
  592.            
  593.            Your crash message will always be displayed if a compile-time
  594.            error (syntax, undeclared variable etc.) occurs. In the case of
  595.            a run-time error (subscript out of bounds, uninitialized 
  596.            variable, divide by zero etc.) your program must be executed
  597.            by the Complete Edition EX.EXE, or have been bound using
  598.            the Complete Edition PDEX.EXE, or be under 300 statements.
  599.  
  600.  Example:     crash_message("An unexpected error has occurred!\n" &
  601.                  "Please contact john_doe@whoops.com\n" & 
  602.                  "Do not delete the file \"ex.err\".\n")
  603.  
  604.  See Also:    abort
  605.            Debugging section of refman.doc
  606.  
  607. ─────────────────────────────────<current_dir>──────────────────────────────────
  608.  
  609.  Syntax:      include file.e
  610.            s = current_dir()
  611.     
  612.  Description: Return the name of the current working directory.
  613.  
  614.  Example:
  615.            sequence s
  616.            s = current_dir()
  617.            -- s would have "C:\EUPHORIA\DOC" if you were in that directory
  618.            
  619.  See Also:    dir, getenv
  620.  
  621. ────────────────────────────────────<cursor>────────────────────────────────────
  622.  
  623.  Syntax:      include graphics.e  
  624.            cursor(i)
  625.     
  626.  Description: Select a style of cursor. graphics.e contains:
  627.         
  628.         global constant NO_CURSOR      = #2000,
  629.              UNDERLINE_CURSOR       = #0607,
  630.              THICK_UNDERLINE_CURSOR = #0507,
  631.              HALF_BLOCK_CURSOR      = #0407,
  632.              BLOCK_CURSOR           = #0007
  633.            
  634.            The second and fourth hex digits (from the left) determine the 
  635.            top and bottom rows of pixels in the cursor. The first digit 
  636.            controls whether the cursor will be visible or not. For example,
  637.            #0407 turns on the 4th through 7th rows.
  638.            
  639.  Example:     cursor(BLOCK_CURSOR)
  640.  
  641. ─────────────────────────────────────<date>─────────────────────────────────────
  642.  
  643.  Syntax:      s = date()
  644.     
  645.  Description: Return a sequence with the following information:
  646.          { year (since 1900),
  647.            month (January = 1),
  648.            day (day of month, starting at 1),
  649.            hour (0 to 23),
  650.            minute (0 to 59),
  651.            second (0 to 59),
  652.            day of the week (Sunday = 1),
  653.            day of the year (January 1st = 1) }
  654.  
  655.  Example:     now = date()
  656.            -- now has: {95,3,24,23,47,38,6,83}
  657.            -- i.e. Friday March 24, 1995 at 11:47:38pm, day 83 of the year
  658.  
  659.  See Also:    time
  660.  
  661. ─────────────────────────────────────<dir>──────────────────────────────────────
  662.  
  663.  Syntax:      include file.e
  664.            x = dir(st)
  665.     
  666.  Description: Return directory information for the file or directory named by
  667.             st. If there is no file or directory with this name then -1 is
  668.             returned.
  669.             
  670.            This information is similar to what you would get from the DOS
  671.            DIR command. A sequence is returned where each element is a 
  672.            sequence that describes one file or subdirectory. 
  673.           
  674.           If st names a directory you may have entries for "." and "..",
  675.           just as with the DOS DIR command. If st names a file then x will
  676.           have just one entry, i.e. length(x) will be 1. 
  677.           
  678.           Each entry contains the name, attributes and file size as well 
  679.           as the year, month, day, hour, minute and second of the last 
  680.           modification. You can refer to the elements of an entry with 
  681.           the following constants defined in file.e:
  682.         
  683.         global constant 
  684.             D_NAME = 1,
  685.             D_ATTRIBUTES = 2,
  686.             D_SIZE = 3,
  687.  
  688.             D_YEAR = 4,
  689.             D_MONTH = 5,
  690.             D_DAY = 6,
  691.  
  692.             D_HOUR = 7,
  693.             D_MINUTE = 8,
  694.             D_SECOND = 9
  695.           
  696.           The attributes element is a string sequence containing 
  697.           characters chosen from:
  698.  
  699.             d - directory
  700.             r - read only file
  701.             h - hidden file
  702.             s - system file
  703.             v - volume-id entry
  704.             a - archive file
  705.  
  706.           A normal file without special attributes would just have an empty
  707.           string, "", in this field. 
  708.         
  709.  Comments:    The top level directory, e.g. c:\ does not have "." or ".."
  710.           entries. 
  711.           
  712.           This function is often used just to test if a file or 
  713.           directory exists.
  714.           
  715.           Under Windows 95, st can have a long file or directory name 
  716.           anywhere in the path.
  717.            
  718.           The file name returned in D_NAME will be a standard DOS 8.3 name,
  719.           even on Windows 95 or Windows NT. A new long-filename element
  720.           may be added in a future release of Euphoria.
  721.  
  722.  Example:      
  723.           d = dir(current_dir()) 
  724.           
  725.           -- d might have:
  726.         {
  727.              {".",    "d",     0  1994, 1, 18,  9, 30, 02},
  728.              {"..",   "d",     0  1994, 1, 18,  9, 20, 14},
  729.              {"fred", "ra", 2350, 1994, 1, 22, 17, 22, 40},
  730.              {"sub",  "d" ,    0, 1993, 9, 20,  8, 50, 12}
  731.         } 
  732.           
  733.           d[3][D_NAME] would be "fred"
  734.           
  735.  Example Programs: bin\search.ex, install.ex
  736.  
  737.  See Also: wildcard_file, current_dir, open
  738.  
  739. ────────────────────────────────<display_image>─────────────────────────────────
  740.  
  741.  Syntax:      include image.e
  742.            display_image(s1, s2)
  743.            
  744.  Description: Display at point s1 on the screen the 2-d sequence of pixels 
  745.            contained in s2. s1 is a two-element sequence {x, y}. s2 is a 
  746.            sequence of sequences, where each sequence is one horizontal 
  747.            line of pixel colors to be displayed. The first pixel of the 
  748.            first sequence is displayed at s1. It is the top-left pixel. 
  749.            All other pixels appear to the right or below of this point.
  750.  
  751.  Comments:    s2 might be the result of a previous call to save_image(), or
  752.            read_bitmap(), or it could be something you have created.
  753.           
  754.           You could use save_image/display_image in a graphical user 
  755.           interface, to allow "pop-up" dialog boxes, and drop-down menus
  756.           to appear and disappear without losing what was previously on 
  757.           the screen.
  758.           
  759.           The sequences (rows) of the image do not have to all be the
  760.           same length.
  761.           
  762.  Example:     display_image({20,30}, {{1,5,9}, 
  763.                        {2,4}, 
  764.                        {1,0,1,0,4}, 
  765.                        {5,5,5}})
  766.            -- displays a small 4-line image at {20,30}, with the pixels
  767.               appearing in the same relative positions as the layout
  768.               above would indicate
  769.  
  770.  Example Program: see demo\bitmap.ex
  771.  
  772.  See Also:    save_image, read_bitmap, display_text_image
  773.  
  774. ─────────────────────────────<display_text_image>───────────────────────────────
  775.  
  776.  Syntax:      include image.e
  777.            display_text_image(s1, s2)
  778.  
  779.  Description: Display the 2-d sequence of characters and attributes contained
  780.             in s2 at line s1[1], column s1[2]. s2 is a sequence of sequences,
  781.             where each sequence is a string of characters and attributes to 
  782.             be displayed. The top-left character is displayed at s1. Other 
  783.             characters appear to the right or below of this position. The
  784.             attributes indicate the foreground and background color of the 
  785.             preceding character.
  786.             
  787.  Comments:    s2 would normally be the result of a previous call to 
  788.            save_text_image(), although you could construct it yourself.
  789.           
  790.           This routine only works in text modes.
  791.           
  792.           You might use save_text_image/display_text_image in a text-mode
  793.           graphical user interface, to allow "pop-up" dialog boxes, and 
  794.           drop-down menus to appear and disappear without losing what was
  795.           previously on the screen.
  796.  
  797.            The sequences of the text image do not have to all be the same
  798.            length.
  799.            
  800.  Example:     clear_screen()
  801.            display_text_image({1,1}, {{'A', WHITE, 'B', GREEN},
  802.                        {'C', RED+16*WHITE},
  803.                        {'D', BLUE}})
  804.            -- displays:  AB
  805.                      C
  806.                      D
  807.              in the appropriate colors at the top left corner of the screen
  808.  
  809.  See Also:    save_text_image, display_image
  810.  
  811. ────────────────────────────────<dos_interrupt>─────────────────────────────────
  812.  Syntax:      include machine.e
  813.            s2 = dos_interrupt(i, s1)
  814.            
  815.  Description: Call DOS software interrupt number i. s1 is a 10-element 
  816.           sequence of 16-bit register values to be used as input to the
  817.           routine. s2 is a similar 10-element sequence containing
  818.           output register values after the call returns. machine.e
  819.           has the following declaration which shows the order of
  820.           the register values in the input and output sequences.
  821.  
  822.         global constant REG_DI = 1,      
  823.                 REG_SI = 2,
  824.                 REG_BP = 3,
  825.                 REG_BX = 4,
  826.                 REG_DX = 5,
  827.                 REG_CX = 6,
  828.                 REG_AX = 7,
  829.                 REG_FLAGS = 8, 
  830.                 REG_ES = 9,
  831.                 REG_DS = 10
  832.  
  833.  Comments:    The register values returned in s2 are always positive values 
  834.            between 0 and #FFFF (65535). 
  835.  
  836.            The flags value in s1[REG_FLAGS] is ignored on input. On output
  837.           the least significant bit of s2[REG_FLAGS] has the carry flag, 
  838.           which usually indicates failure if it is set to 1.
  839.  
  840.           Certain interrupts require that you supply addresses of blocks of
  841.           memory. These addresses must be conventional, low-memory
  842.           addresses. You can allocate/deallocate low-memory using 
  843.           allocate_low() and free_low().
  844.           
  845.           With DOS software interrupts you can perform a wide variety
  846.           of specialized operations, anything from formatting your 
  847.           floppy drive to rebooting your computer. For documentation
  848.           on these interrupts consult a technical manual such as
  849.           Peter Norton's "PC Programmer's Bible", or download Ralf
  850.           Brown's Interrupt List from the WEB:
  851.      
  852.            http://www.cs.cmu.edu/afs/cs.cmu.edu/user/ralf/pub/WWW/files.html
  853.  
  854.  Example Program: demo\dosint.ex
  855.  
  856.  See Also:      allocate_low, free_low
  857.  
  858. ──────────────────────────────────<draw_line>───────────────────────────────────
  859.  
  860.  Syntax:      include graphics.e
  861.            draw_line(i, s)
  862.     
  863.  Description: Draw a line connecting two or more points in s, using color i. 
  864.  
  865.  Example:     draw_line(WHITE, {{100, 100}, {200, 200}, {900, 700}}) 
  866.  
  867.           This would connect the three points in the sequence using a white
  868.           line, i.e. a line would be drawn from {100, 100} to {200, 200} 
  869.           and another line would be drawn from {200, 200} to {900, 700}.
  870.  
  871.  See Also:    polygon, ellipse, pixel
  872.  
  873. ───────────────────────────────────<ellipse>────────────────────────────────────
  874.  
  875.  Syntax:      include graphics.e
  876.            ellipse(i1, i2, s1, s2)
  877.     
  878.  Description: Draw an ellipse with color i1. The ellipse will neatly fit inside
  879.           the rectangle defined by diagonal points s1 {x1, y1} and s2 
  880.           {x2, y2}. If the rectangle is a square then the ellipse will be a
  881.           circle. Fill the ellipse when i2 is 1. Don't fill when i2 is 0. 
  882.  
  883.  Example:     ellipse(MAGENTA, 0, {10, 10}, {20, 20})
  884.  
  885.           This would make a magenta colored circle just fitting inside the
  886.           square: {10, 10}, {10, 20}, {20, 20}, {20, 10}.
  887.  
  888.  Example Program: demo\sb.ex
  889.  
  890.  See Also:    polygon, draw_line
  891.  
  892. ─────────────────────────────────────<find>─────────────────────────────────────
  893.  
  894.  Syntax:      i = find(x, s)
  895.  
  896.  Description: Find x as an element of s. If successful, return the index 
  897.            of the first element of s that matches. If unsuccessful 
  898.            return 0. 
  899.     
  900.  Example 1:   location = find(11, {5, 8, 11, 2, 3})
  901.           -- location is set to 3
  902.  
  903.  Example 2:   names = {"fred", "rob", "george", "mary", ""}
  904.           location = find("mary", names)
  905.           -- location is set to 4
  906.  
  907.  See Also:    match, compare
  908.  
  909. ────────────────────────────────────<floor>─────────────────────────────────────
  910.  
  911.  Syntax:      x2 = floor(x1)
  912.     
  913.  Description: Return the greatest integer less than or equal to x1. (Round
  914.            down to an integer.)
  915.  
  916.  Comments:    This function may be applied to an atom or to all elements
  917.            of a sequence.
  918.            
  919.  Example:     y = floor({0.5, -1.6, 9.99, 100})
  920.            -- y is {0, -2, 9, 100}
  921.  
  922.  See Also:    remainder
  923.  
  924. ─────────────────────────────────────<free>─────────────────────────────────────
  925.  
  926.  Syntax:      include machine.e
  927.            free(a)
  928.     
  929.  Description: Free up a previously allocated block of memory by specifying the
  930.           address of the start of the block, i.e. the address that was
  931.           returned by allocate(). 
  932.  
  933.  Comments:    Use free() to recycle blocks of memory during execution. This
  934.             will reduce the chance of running out of memory or getting into 
  935.             excessive virtual memory swapping to disk. Do not reference 
  936.             a block of memory that has been freed. When your program 
  937.             terminates, all allocated memory will be returned to the system. 
  938.            
  939.            Do not use free() to deallocate memory that was allocated using
  940.            allocate_low(). Use free_low() for this purpose.
  941.            
  942.  Example Program: demo\callmach.ex
  943.  
  944.  See Also:    allocate, free_low
  945.  
  946. ───────────────────────────────────<free_low>───────────────────────────────────
  947.  
  948.  Syntax:      include machine.e
  949.            free_low(i)
  950.     
  951.  Description: Free up a previously allocated block of conventional memory by 
  952.            specifying the address of the start of the block, i.e. the 
  953.            address that was returned by allocate_low(). 
  954.  
  955.  Comments:    Use free_low() to recycle blocks of conventional memory during 
  956.            execution. This will reduce the chance of running out of 
  957.            conventional memory. Do not reference a block of memory that has
  958.            been freed. When your program terminates, all allocated memory 
  959.            will be returned to the system. 
  960.            
  961.            Do not use free_low() to deallocate memory that was allocated 
  962.            using allocate(). Use free() for this purpose.
  963.            
  964.  Example Program: demo\dosint.ex
  965.  
  966.  See Also:    allocate_low, dos_interrupt, free
  967.  
  968. ─────────────────────────────────────<get>──────────────────────────────────────
  969.  
  970.  Syntax:      include get.e
  971.            s = get(fn)
  972.  
  973.  Description: Read the next string of characters representing a Euphoria object
  974.             from file fn, and convert it into the numeric value of that 
  975.             object. The result s will be a 2-element sequence: 
  976.             {error status, value}. Error status values are:
  977.  
  978.         GET_SUCCESS  -- object was read successfully
  979.         GET_EOF      -- end of file before object was read
  980.         GET_FAIL     -- object is not syntactically correct
  981.  
  982.           get() can read arbitrarily complicated Euphoria objects. You 
  983.           could have a long sequence of values in braces and separated by 
  984.           commas, e.g. {23, {49, 57}, 0.5, -1, 99, 'A', "john"}. A single
  985.           call to get() will read in this entire sequence and return it's
  986.           value as a result. 
  987.     
  988.           Each call to get() picks up where the previous call left off. For 
  989.           instance, a series of 5 calls to get() would be needed to read 
  990.           in: 
  991.     
  992.         99  5.2  {1,2,3}  "Hello"  -1
  993.  
  994.            On the sixth and any subsequent call to get() you would see a
  995.            GET_EOF status. If you had something like:
  996.            
  997.              {1,2,xxx}
  998.            
  999.            in the input stream you would see a GET_FAIL error status
  1000.            because xxx is not a Euphoria object.
  1001.            
  1002.            Distinct "top-level" objects in the input stream must be 
  1003.            separated from each other with one or more "whitespace" 
  1004.            characters (blank, tab or \n). Whitespace is not necessary 
  1005.            *within* a top-level object.
  1006.            
  1007.  Comments:    The combination of print() and get() can be used to save any 
  1008.            Euphoria object to disk and later read it back. This technique
  1009.            could be used to implement a database as one or more large 
  1010.            Euphoria sequences stored in disk files. The sequences could be
  1011.            read into memory, updated and then written back to disk after
  1012.            each series of transactions is complete. 
  1013.  
  1014.            The value returned is not meaningful unless you have a 
  1015.            GET_SUCCESS status.
  1016.            
  1017.  Example:     Suppose your program asks the user to enter a number from the
  1018.             keyboard. If he types 77.5, get(0) would return:
  1019.                  
  1020.                  {GET_SUCCESS, 77.5} 
  1021.             
  1022.             whereas gets(0) would return
  1023.               
  1024.               "77.5\n" 
  1025.  
  1026.  Example Program: see demo\mydata.ex. 
  1027.  
  1028.  See Also:    print, value, gets, getc
  1029.  
  1030. ───────────────────────────────<get_active_page>────────────────────────────────
  1031.  
  1032.  Syntax:      include image.e
  1033.            i = get_active_page()
  1034.  
  1035.  Description: Some graphics modes on most video cards have multiple pages
  1036.            of memory. This lets you write screen output to one page
  1037.            while displaying a different page. get_active_page() returns
  1038.            the current page number that screen output is being sent to.
  1039.            
  1040.  Comments:    The active and display pages are both 0 by default.
  1041.           
  1042.           video_config() will tell you how many pages are available in
  1043.           the current graphics mode.
  1044.  
  1045.  See Also:    set_active_page, get_display_page, video_config
  1046.  
  1047. ───────────────────────────────<get_display_page>───────────────────────────────
  1048.  
  1049.  Syntax:      include image.e
  1050.            i = get_display_page()
  1051.  
  1052.  Description: Some graphics modes on most video cards have multiple pages
  1053.            of memory. This lets you write screen output to one page
  1054.            while displaying another. get_display_page() returns the current
  1055.            page number that is being displayed on the monitor.
  1056.            
  1057.  Comments:    The active and display pages are both 0 by default.
  1058.  
  1059.           video_config() will tell you how many pages are available in
  1060.           the current graphics mode.
  1061.  
  1062.  See Also:    set_display_page, get_active_page, video_config
  1063.  
  1064. ───────────────────────────────────<get_key>────────────────────────────────────
  1065.  
  1066.  Syntax:      i = get_key()
  1067.     
  1068.  Description: Return the key that was pressed by the user, without waiting for 
  1069.           carriage return. Return -1 if no key was pressed. Special
  1070.           codes are returned for the function keys, arrow keys etc.
  1071.  
  1072.  Comments:    DOS can hold a small number of key-hits in its keyboard buffer. 
  1073.            get_key() will return the next one from the buffer, or -1 if 
  1074.            the buffer is empty.
  1075.  
  1076.            Run the key.bat program to see what key code is generated for
  1077.            each key on your keyboard.
  1078.            
  1079.  See Also:    wait_key, getc
  1080.  
  1081. ──────────────────────────────────<get_mouse>───────────────────────────────────
  1082.  
  1083.  Syntax:      include mouse.e
  1084.            x = get_mouse()
  1085.     
  1086.  Description: Return the last mouse event in the form:
  1087.           
  1088.           {event, x, y} 
  1089.             
  1090.             or return -1 if there has not been a mouse event since the last
  1091.             time get_mouse() was called. 
  1092.  
  1093.           Constants have been defined in mouse.e for the possible mouse
  1094.           events: 
  1095.     
  1096.             global constant MOVE = 1,  
  1097.                     LEFT_DOWN = 2,
  1098.                     LEFT_UP = 4,
  1099.                     RIGHT_DOWN = 8,
  1100.                     RIGHT_UP = 16,
  1101.                     MIDDLE_DOWN = 32,
  1102.                     MIDDLE_UP = 64
  1103.     
  1104.           x and y are the coordinates of the mouse pointer at the time that 
  1105.           the event occurred. get_mouse() returns immediately with either 
  1106.           a -1 or a mouse event. It does not wait for an event to occur. 
  1107.           You must check it frequently enough to avoid missing an event.
  1108.           When the next event occurs, the current event will be lost, if 
  1109.           you haven't read it. In practice it is not hard to catch almost
  1110.           all events, and the ones that are lost are usually lost at a 
  1111.           lower level in the system, beyond the control of your program.
  1112.           Losing a MOVE event is generally not too serious, as the next 
  1113.           MOVE will tell you where the mouse pointer is. 
  1114.  
  1115.  Comments:    You need a DOS mouse driver to use this routine.
  1116.             
  1117.            You can use get_mouse() in most text and graphics modes. 
  1118.           
  1119.             The first call that you make to get_mouse() will turn on a
  1120.             mouse pointer, or a highlighted character.
  1121.            
  1122.           In text modes you will probably want to scale the x and y 
  1123.           coordinates to get line and column positions.
  1124.           
  1125.           DOS generally does not support the use of a mouse in SVGA 
  1126.           graphics modes (beyond 640x480 pixels). This restriction
  1127.           has been removed in Windows 95 (DOS 7.0).
  1128.           
  1129.           The x,y coordinate returned could be that of the very tip of the
  1130.           mouse pointer or might refer to the pixel pointed-to by
  1131.           the mouse pointer. Test this if you are trying to read the
  1132.           pixel color using get_pixel. You may have to read x-1,y-1
  1133.           instead.
  1134.  
  1135.  Example:     a return value of:
  1136.          
  1137.          {2, 100, 50} 
  1138.            
  1139.            would indicate that the left button was pressed down while the
  1140.            mouse pointer was at position x=100, y=50 on the screen.     
  1141.  
  1142.  See Also:    mouse_events, mouse_pointer
  1143.  
  1144. ──────────────────────────────────<get_pixel>───────────────────────────────────
  1145.  
  1146.  Syntax:      include graphics.e
  1147.            x = get_pixel(s)
  1148.     
  1149.  Description: When s is a 2-element screen coordinate {x, y}, get_pixel() 
  1150.            returns the color of the pixel on the screen at that point. 
  1151.            
  1152.            When s is a 3-element sequence of the form: {x, y, n}
  1153.            get_pixel() returns a sequence of n color values for the
  1154.            points starting at {x,y} and moving to the right {x+1,y},
  1155.            {x+2,y} etc.
  1156.  
  1157.            Points off the screen have unpredictable color values.
  1158.  
  1159.  Comments:    When n is specified, a very fast algorithm is used to read the
  1160.            pixel colors on the screen. It is much faster to call get_pixel() 
  1161.            once, specifying a large value of n, than it is to call it many
  1162.            times, reading one pixel color at a time.
  1163.  
  1164.  Example:     object x
  1165.      
  1166.            x = get_pixel({30,40})
  1167.            -- x is set to the color value of point x=30, y=40
  1168.            
  1169.            x = get_pixel({30,40,100})
  1170.            -- x is set to a sequence of 100 integer values, representing
  1171.            -- the colors starting at {30,40} and going to the right
  1172.  
  1173.  See Also:    pixel, graphics_mode, get_position
  1174.  
  1175. ─────────────────────────────────<get_position>─────────────────────────────────
  1176.  
  1177.  Syntax:      include graphics.e
  1178.            s = get_position()
  1179.      
  1180.  Description: Return the current line and column position of the cursor as a 
  1181.            2-element sequence {line, column}.
  1182.  
  1183.  See Also:    position, get_pixel
  1184.  
  1185. ─────────────────────────────────────<getc>─────────────────────────────────────
  1186.  
  1187.  Syntax:      i = getc(fn)
  1188.     
  1189.  Description: Get the next character (byte) from file fn. -1 is returned at end 
  1190.           of file.
  1191.           
  1192.  Comments:    File input using getc is buffered, i.e. getc does not actually 
  1193.            go out to the disk for each character. Instead, a large block of 
  1194.            characters will be read in at one time and returned to you one 
  1195.            by one from a memory buffer.
  1196.            
  1197.  See Also:    gets, get_key, wait_key, open
  1198.  
  1199. ────────────────────────────────────<getenv>────────────────────────────────────
  1200.  
  1201.  Syntax:      x = getenv(s)
  1202.     
  1203.  Description: Return the value of a DOS environment variable. If the variable
  1204.             is undefined return -1.
  1205.     
  1206.  Example:     e = getenv("EUDIR")
  1207.           -- e will be "C:\EUPHORIA" -- or perhaps D:, E: etc.
  1208.  
  1209.  Comments:    Because either a sequence or an atom (-1) might be returned, you 
  1210.            should probably assign the result to a variable declared as 
  1211.            object.
  1212.  
  1213.  See Also:    command_line
  1214.            
  1215. ─────────────────────────────────────<gets>─────────────────────────────────────
  1216.  
  1217.  Syntax:      x = gets(fn)
  1218.     
  1219.  Description: Get the next sequence (one line, including '\n') of characters 
  1220.            from file fn. The atom -1 is returned on end of file. 
  1221.           
  1222.  Comments:    Because either a sequence or an atom (-1) might be returned, you 
  1223.            should probably assign the result to a variable declared as 
  1224.            object.
  1225.  
  1226.            The last line in a file might not end with a new-line '\n' 
  1227.            character.
  1228.  
  1229.  Example:
  1230.           sequence buffer
  1231.           object line
  1232.         
  1233.           -- read a text file into a sequence
  1234.           buffer = {}
  1235.           while 1 do
  1236.                line = gets(0)
  1237.                if atom(line) then
  1238.               exit   -- end of file
  1239.                end if
  1240.                buffer = append(buffer, line)
  1241.           end while
  1242.  
  1243.  See Also:    getc, puts, open
  1244.  
  1245. ────────────────────────────────<graphics_mode>─────────────────────────────────
  1246.  
  1247.  Syntax:      include graphics.e
  1248.            i1 = graphics_mode(i2)
  1249.     
  1250.  Description: Select graphics mode i2. See graphics.e for a list of valid 
  1251.           graphics modes. If successful, i1 is set to 0, otherwise i1
  1252.           is set to 1.
  1253.  
  1254.  Comment:     Some modes are referred to as "text" modes because they only
  1255.            let you display text. Other modes are referred to as "graphics"
  1256.            modes because you can display pixels, lines, ellipses, etc. and 
  1257.            usually text as well.
  1258.             
  1259.            As a convenience to your users, it is usually a good idea to 
  1260.            switch back from a pixel graphics mode to the standard text 
  1261.            mode before your program terminates. You can do this with 
  1262.            graphics_mode(-1). If a graphics program leaves your screen
  1263.            in a mess, you can clear it up with the DOS CLS command, or
  1264.            by running ex or ed.
  1265.            
  1266.  Example:     if graphics_mode(18) then
  1267.                puts(SCREEN, "need VGA graphics!\n")
  1268.                  abort(1)
  1269.            end if
  1270.            draw_line(BLUE, {{0,0}, {50,50}})
  1271.  
  1272.  See Also:    text_rows, video_config
  1273.  
  1274. ─────────────────────────────────<int_to_bits>──────────────────────────────────
  1275.  
  1276.  Syntax:      include machine.e
  1277.            s = int_to_bits(a, i)
  1278.  
  1279.  Description: Returns the low-order i bits of a, as a sequence of 1's and 0's.
  1280.            The least significant bits come first. For negative numbers
  1281.            the two's complement bit pattern is returned.
  1282.            
  1283.  Comments:    You can use subscripting, slicing, and/or/not of entire 
  1284.            sequences etc. to manipulate sequences of bits. Shifting 
  1285.            of bits and rotating of bits are easy to perform.
  1286.  
  1287.  Example:     s = int_to_bits(177, 8)
  1288.            -- s is {1,0,0,0,1,1,0,1} -- "reverse" order
  1289.             
  1290.  See Also:    bits_to_int, and/or/not of entire sequences in refman.doc
  1291.  
  1292. ─────────────────────────────────<int_to_bytes>─────────────────────────────────
  1293.  
  1294.  Syntax:      include machine.e
  1295.            s = int_to_bytes(a)
  1296.     
  1297.  Description: Convert an integer into a sequence of 4 bytes. These bytes are in
  1298.           the order expected on the 386+, i.e. least significant byte 
  1299.           first.
  1300.     
  1301.  Comments:    You might use this routine prior to poking the 4 bytes into 
  1302.            memory for use by a machine language program.
  1303.      
  1304.           The integer can be negative. Negative byte-values will be
  1305.           returned, but after poking them into memory you will have 
  1306.           the correct (two's complement) representation for the 386+.
  1307.            
  1308.  Example 1:   s = int_to_bytes(999)
  1309.            -- s is {231, 3, 0, 0}
  1310.  
  1311.  Example 2:   s = int_to_bytes(-999)
  1312.            -- s is {-231, -4, -1, -1}
  1313.            
  1314.  See Also:    bytes_to_int, int_to_bits, bits_to_int, peek, poke
  1315.  
  1316. ───────────────────────────────────<integer>────────────────────────────────────
  1317.                   
  1318.  Syntax:      i = integer(x)
  1319.     
  1320.  Description: Return 1 if x is an integer in the range -1073741824 to 
  1321.            +1073741823. Otherwise return 0.  
  1322.  
  1323.  Comments:    This serves to define the integer type. You can also call it 
  1324.            like an ordinary function to determine if an object is an
  1325.            integer.
  1326.       
  1327.  Example 1:   integer z
  1328.            z = -1
  1329.            
  1330.  Example 2:   if integer(y/x) then
  1331.                puts(SCREEN, "y is an exact multiple of x")
  1332.            end if
  1333.  
  1334.  See Also:    atom, sequence, floor
  1335.  
  1336. ────────────────────────────────────<length>────────────────────────────────────
  1337.  
  1338.  Syntax:      i = length(s)
  1339.     
  1340.  Description: Return the length of s. s must be a sequence. An error will
  1341.            occur if s is an atom.
  1342.  
  1343.  Comments:    The length of each sequence is stored internally by the
  1344.            interpreter for quick access. (In other languages this
  1345.            operation requires a search through memory for an end marker.)
  1346.         
  1347.  Example 1:   length({{1,2}, {3,4}, {5,6}})   -- 3
  1348.  
  1349.  Example 2:   length("")    -- 0
  1350.  
  1351.  Example 3:   length({})    -- 0
  1352.  
  1353. ─────────────────────────────────────<log>──────────────────────────────────────
  1354.  
  1355.  Syntax:      x2 = log(x1)
  1356.     
  1357.  Description: Return the natural logarithm of x1.
  1358.  
  1359.  Comments:    This function may be applied to an atom or to all elements
  1360.            of a sequence. Note that log is only defined for positive
  1361.            numbers. Your program will abort with a message if you
  1362.            try to take the log of a negative number or zero.
  1363.  
  1364.  Example:     a = log(100)
  1365.            -- a is 4.60517
  1366.  
  1367.  See Also:    sin, cos, tan, sqrt
  1368.  
  1369. ────────────────────────────────────<lower>─────────────────────────────────────
  1370.  
  1371.  Syntax:      include wildcard.e
  1372.            s2 = lower(s1)
  1373.  
  1374.  Description: Convert a string of characters to lower case.
  1375.  
  1376.  Example:     s = lower("Euphoria")
  1377.            -- s is "euphoria"
  1378.            
  1379.  See Also:    upper
  1380.  
  1381. ─────────────────────────────────<machine_func>─────────────────────────────────
  1382.  
  1383.  Syntax:      x = machine_func(a, x)
  1384.  
  1385.  Description: see machine_proc() below
  1386.  
  1387. ─────────────────────────────────<machine_proc>─────────────────────────────────
  1388.  
  1389.  Syntax:      machine_proc(a, x) 
  1390.     
  1391.  Description: Perform a machine-specific operation such as graphics and sound
  1392.             effects. This routine should normally be called indirectly via 
  1393.             one of the library routines in a Euphoria include file. A direct
  1394.             call can cause a machine exception if done incorrectly.
  1395.  
  1396.  See Also:    machine_func
  1397.  
  1398. ────────────────────────────────────<match>─────────────────────────────────────
  1399.  
  1400.  Syntax:      i = match(s1, s2)
  1401.  
  1402.  Description: Try to match s1 against some slice of s2. If successful, return 
  1403.           the element number of s2 where the (first) matching slice begins, 
  1404.           else return 0. 
  1405.           
  1406.  Example:     location = match("pho", "Euphoria")
  1407.           -- location is set to 3
  1408.  
  1409.  See Also:    find, compare, wildcard_match
  1410.  
  1411. ─────────────────────────────────<mouse_events>─────────────────────────────────
  1412.  
  1413.  Syntax:      include mouse.e
  1414.            mouse_events(i) 
  1415.     
  1416.  Description: Use this procedure to select the mouse events that you want 
  1417.           get_mouse() to report. By default, get_mouse() will report all
  1418.           events. mouse_events() can be called at various stages of the 
  1419.           execution of your program, as the need to detect events changes.
  1420.  
  1421.  Comments:    It is good practice to ignore events that you are not interested
  1422.               in, particularly the very frequent MOVE event, in order to reduce
  1423.               the chance that you will miss a significant event.
  1424.  
  1425.             The first call that you make to mouse_events() will turn on a
  1426.             mouse pointer, or a highlighted character.
  1427.  
  1428.  Example:     mouse_events(LEFT_DOWN + LEFT_UP + RIGHT_DOWN) 
  1429.            -- will restrict get_mouse() to reporting the left button 
  1430.              being pressed down or released, and the right button 
  1431.              being pressed down. All other events will be ignored. 
  1432.  
  1433.  See Also:    get_mouse, mouse_pointer
  1434.  
  1435. ────────────────────────────────<mouse_pointer>─────────────────────────────────
  1436.  
  1437.  Syntax:      include mouse.e
  1438.            mouse_pointer(i)
  1439.     
  1440.  Description: If i is 0 hide the mouse pointer, otherwise turn on the mouse 
  1441.            pointer. Multiple calls to hide the pointer will require
  1442.           multiple calls to turn it back on. The first call to either 
  1443.           get_mouse() or mouse_events() above, will also turn the pointer
  1444.           on (once).
  1445.     
  1446.  Comments:    It may be necessary to hide the mouse pointer temporarily when
  1447.             you update the screen. 
  1448.  
  1449.  See Also:    get_mouse, mouse_events
  1450.  
  1451. ─────────────────────────────────────<open>─────────────────────────────────────
  1452.  
  1453.  Syntax:      fn = open(s1, s2)
  1454.     
  1455.  Description: Open a file or device, to get the file number. -1 is returned if
  1456.             the open fails. s1 is the path name of the file or device.  s2 is
  1457.             the mode in which the file is to be opened. Possible modes are:
  1458.           
  1459.           "r"  - open text file for reading
  1460.           "rb" - open binary file for reading
  1461.           "w"  - create text file for writing
  1462.           "wb" - create binary file for writing
  1463.           "u"  - open text file for update (reading and writing)
  1464.           "ub" - open binary file for update
  1465.           "a"  - open text file for appending
  1466.           "ab" - open binary file for appending
  1467.  
  1468.           Files opened for read or update must already exist. Files opened
  1469.           for write or append will be created if necessary. A file opened 
  1470.           for write will be set to 0 bytes. Output to a file opened for
  1471.           append will start at the end of file.
  1472.  
  1473.           Output to text files will have carriage-return characters 
  1474.           automatically added before linefeed characters. On input, these 
  1475.           carriage-return characters are removed. A control-Z character 
  1476.           (ASCII 26) will signal an immediate end of file. 
  1477.     
  1478.           I/O to binary files is not modified in any way. Any byte values 
  1479.           from 0 to 255 can be read or written.
  1480.  
  1481.           Some typical devices that you can open are:
  1482.           
  1483.           "CON"    the console (screen)
  1484.           "AUX"    the serial auxiliary port 
  1485.           "COM1"   serial port 1
  1486.           "COM2"   serial port 2
  1487.           "PRN"    the printer on the parallel port
  1488.           "NUL"    a non-existent device that accepts and discards output 
  1489.  
  1490.  Comment:     When running under Windows 95, you can open any existing file
  1491.            that has a long file or directory name in its path (i.e. greater
  1492.            than the standard DOS 8.3 format) using any open mode - read, 
  1493.            write etc. However, if you try to create a *new* file (open with 
  1494.            "w" or "a" and the file does not already exist) then the name 
  1495.            will be truncated if necessary to an 8.3 style name. We hope to 
  1496.            support creation of new long-filename files in a future release.
  1497.            
  1498.  Example:     integer file_num, file_num95
  1499.            sequence first_line
  1500.            constant ERROR = 2
  1501.            
  1502.            file_num = open("myfile", "r")
  1503.           if file_num = -1 then           
  1504.                  puts(ERROR, "couldn't open myfile\n")
  1505.            else
  1506.                first_line = gets(file_num)
  1507.            end if
  1508.            
  1509.            -- on Windows 95:
  1510.            file_num95 = open("bigdirectoryname\\verylongfilename.abcdefg", 
  1511.                        "r")
  1512.            if file_num95 != -1 then
  1513.            puts(1, "it worked!\n")
  1514.            end if
  1515.  
  1516.  See Also:    close
  1517.  
  1518. ───────────────────────────────────<palette>────────────────────────────────────
  1519.  
  1520.  Syntax:      include graphics.e     
  1521.            x = palette(i, s)
  1522.     
  1523.  Description: Change the color for color number i to s, where s is a sequence 
  1524.            of color intensities: {red, green, blue}. Each value in s can be
  1525.            from 0 to 63. If successful, a 3-element sequence containing the 
  1526.           previous color for i will be returned, and all pixels on the 
  1527.           screen with value i will be set to the new color. If 
  1528.           unsuccessful, the atom -1 will be returned. 
  1529.  Example:     
  1530.            x = palette(0, {15, 40, 10})
  1531.            -- color number 0 (normally black) is changed to a shade 
  1532.               of mainly green. 
  1533.            
  1534.  See Also:    all_palette 
  1535.  
  1536. ─────────────────────────────────────<peek>─────────────────────────────────────
  1537.  
  1538.  Syntax:      i = peek(a)
  1539.   or ...      s = peek({a, i})
  1540.        
  1541.  Description: Return a single byte value in the range 0 to 255 from machine 
  1542.            address a, or return a sequence containing i consecutive byte
  1543.            values starting at address a in memory.
  1544.  
  1545.  Comments:    Since addresses are 32-bit numbers, they can be larger than
  1546.            the largest value of type integer (31-bits). Variables that 
  1547.            hold an address should therefore be declared as atoms.
  1548.  
  1549.            It is faster to read several bytes at once using the second
  1550.            form of peek() than it is to read one byte at a time in a
  1551.            loop.
  1552.  
  1553.            Remember that peek takes just one argument, which in the
  1554.            second form is actually a 2-element sequence.
  1555.            
  1556.  Example:     The following are equivalent:
  1557.            -- method 1
  1558.            s = {peek(100), peek(101), peek(102), peek(103)}
  1559.            
  1560.            -- method 2
  1561.            s = peek({100, 4})
  1562.  
  1563.  See Also:    poke, allocate, free, allocate_low, free_low, call
  1564.  
  1565. ────────────────────────────────────<pixel>─────────────────────────────────────
  1566.  
  1567.  Syntax:      include graphics.e
  1568.            pixel(x, s) 
  1569.     
  1570.  Description: Set one or more pixels starting at point s, where s is a 
  1571.            2-element screen coordinate {x, y}. If x is an atom, one pixel 
  1572.            will be set to the color indicated by x. If x is a sequence then
  1573.            a number of pixels will be set, starting at s and moving to the 
  1574.            right (increasing x value, same y value).
  1575.  
  1576.  Comments:    When x is a sequence, a very fast algorithm is used to put the
  1577.            pixels on the screen. It is much faster to call pixel() once,
  1578.            with a sequence of pixel colors, than it is to call it many
  1579.            times, plotting one pixel color at a time.
  1580.            
  1581.  Example 1:   pixel(BLUE, {50, 60})
  1582.           -- the point {50,60} is set to the color BLUE    
  1583.  
  1584.  Example 2:   pixel({BLUE, GREEN, WHITE, RED}, {50,60})
  1585.            -- {50,60} set to BLUE
  1586.            -- {51,60} set to GREEN
  1587.            -- {52,60} set to WHITE
  1588.            -- {53,60} set to RED
  1589.  
  1590.  See Also:    get_pixel, graphics_mode
  1591.  
  1592. ─────────────────────────────────────<poke>─────────────────────────────────────
  1593.  
  1594.  Syntax:      poke(a, i)
  1595.   or ..       poke(a, s)
  1596.   
  1597.  Description: First form - Write a single byte value, i, to memory address a. 
  1598.            
  1599.            Second form - Write a sequence of byte values to consecutive 
  1600.            memory locations starting at location a.
  1601.           
  1602.  Comments:    The lower 8-bits of each byte value, i.e. remainder(value, 256), 
  1603.            is actually stored in memory. 
  1604.  
  1605.            It is faster to write several bytes at once using the second
  1606.            form of poke() than it is to write one byte at a time in a
  1607.            loop.
  1608.  
  1609.            Writing to the screen memory with poke() can be much faster than 
  1610.            using puts() or printf(), but the programming is more difficult. 
  1611.            In most cases the speed is not needed. For example, the Euphoria
  1612.            editor never uses poke().
  1613.  
  1614.  Example Program: see demo\callmach.ex
  1615.  
  1616.  See Also:    peek, allocate, free, allocate_low, free_low, call
  1617.  
  1618. ───────────────────────────────────<polygon>────────────────────────────────────
  1619.  
  1620.  Syntax:      include graphics.e
  1621.            polygon(i1, i2, s)
  1622.     
  1623.  Description: Draw a polygon with 3 or more vertices given in s, using a 
  1624.            certain color i1. Fill the area if i2 is 1. Don't fill if i2 
  1625.            is 0. 
  1626.  
  1627.  Example:     polygon(GREEN, 1, {{100, 100}, {200, 200}, {900, 700}})
  1628.           -- makes a solid green triangle.
  1629.  
  1630.  See Also:    draw_line, ellipse
  1631.  
  1632. ───────────────────────────────────<position>───────────────────────────────────
  1633.  
  1634.  Syntax:      position(a1, a2)
  1635.     
  1636.  Description: Set the cursor to line a1, column a2, where the top left corner 
  1637.           of the screen is line 1, column 1. The next output to the screen
  1638.           will be printed at this location. position() will report an 
  1639.           error if the location is off the screen. 
  1640.  
  1641.  Comments:    The coordinate system for text is different from the one for
  1642.            graphics. In graphics modes the top-left is (x=0,y=0) and the 
  1643.            first coordinate controls the horizontal, left<-->right location.
  1644.  
  1645.  Example:     position(2,1)
  1646.            -- the cursor moves to the beginning of the second line from 
  1647.               the top 
  1648.  
  1649.  See Also:    get_position, puts, print, printf
  1650.  
  1651. ────────────────────────────────────<power>─────────────────────────────────────
  1652.  
  1653.  Syntax:      x3 = power(x1, x2)
  1654.  
  1655.  Description: Raise x1 to the power x2
  1656.  
  1657.  Comments:    The arguments to this functions may be atoms or sequences. The
  1658.            rules for arithmetic operations on sequences apply.
  1659.  
  1660.            Powers of 2 are calculated very efficiently.
  1661.  
  1662.  Example 1:   ? power(5, 2)
  1663.            -- 25 is printed
  1664.  
  1665.  Example 2:   ? power({5, 4, 3.5}, {2, 1, -0.5})  
  1666.            -- {25, 4, 0.534522} is printed
  1667.  
  1668.  Example 3:   ? power(2, {1, 2, 3, 4})
  1669.            -- {2, 4, 8, 16}
  1670.  
  1671.  Example 4:   ? power({1, 2, 3, 4}, 2)
  1672.            -- {1, 4, 9, 16}
  1673.            
  1674.  See Also:    log, sqrt
  1675.  
  1676. ───────────────────────────────────<prepend>────────────────────────────────────
  1677.  
  1678.  Syntax:      s2 = prepend(s1, x)
  1679.     
  1680.  Description: Prepend x to the start of sequence s1. The length of s2 will be 
  1681.           length(s1) + 1. 
  1682.           
  1683.  Comments:    If x is an atom this is the same as s2 = x & s1. If x is a 
  1684.            sequence it is definitely not the same. e.g.
  1685.     
  1686.          prepend({1,2,3}, {0,0})    
  1687.              -- {{0,0}, 1, 2, 3}
  1688.  
  1689.          {0,0} & {1,2,3}        
  1690.                 -- {0, 0, 1, 2, 3}
  1691.  
  1692.            The case where s1 and s2 are the same variable is handled
  1693.            very efficiently.
  1694.  
  1695.  Example:     s = {}
  1696.            for i = 1 to 10 do
  1697.            s = prepend(s, i)
  1698.             end for
  1699.             -- s is {10,9,8,7,6,5,4,3,2,1}
  1700.             
  1701.  See Also:    append, concatenation (&) and sequence-formation {,,} operators 
  1702.            in refman.doc
  1703.  
  1704. ────────────────────────────────────<print>─────────────────────────────────────
  1705.  
  1706.  Syntax:      print(fn, x)
  1707.     
  1708.  Description: Print, to file or device fn, an object x with braces { , , , } 
  1709.            to show the structure.
  1710.           
  1711.  Comment:     If you want to see a string of characters, rather than just the 
  1712.           ASCII codes, you need to use puts or printf. 
  1713.  
  1714.  Example 1:   print(1, "ABC")  -- output is:  {65, 66, 67}
  1715.            puts(1, "ABC")   -- output is:  ABC
  1716.  
  1717.  Example 2:   print(1, repeat({10,20}, 3))
  1718.            -- output is: {{10,20},{10,20},{10,20}}
  1719.            
  1720.  See Also:    ?, puts, printf, get
  1721.  
  1722. ────────────────────────────────────<printf>────────────────────────────────────
  1723.  
  1724.  Syntax:      printf(fn, st, x)
  1725.     
  1726.  Description: Print x, to file or device fn, using format string st. If x is 
  1727.            an atom then a single value will be printed. If x is a sequence, 
  1728.            then formats from st are applied to successive elements of x. 
  1729.            Thus printf always takes exactly 3 arguments. Only the length of 
  1730.            the last argument, containing the values to be printed, will 
  1731.            vary. The basic formats are: 
  1732.           
  1733.           %d - print an atom as a decimal integer
  1734.           %x - print an atom as a hexadecimal integer
  1735.           %o - print an atom as an octal integer
  1736.           %s - print a sequence as a string of characters
  1737.           %e - print an atom as a floating point number with exponential 
  1738.                  notation
  1739.           %f - print an atom as a floating-point number with a decimal
  1740.                point but no exponent
  1741.           %g - print an atom as a floating point number using either
  1742.              the %f or %e format, whichever seems more appropriate
  1743.           %% - print the '%' character itself
  1744.  
  1745.           Field widths can be added to the basic formats, e.g. %5d, or 
  1746.           %8.2f. The number before the decimal point is the minimum field
  1747.           width to be used. The number after the decimal point is the 
  1748.           precision to be used.
  1749.  
  1750.           If the field width is negative, e.g. %-5d then the value will be 
  1751.           left-justified within the field. Normally it will be right-
  1752.           justified. If the field width starts with a leading 0, e.g. %08d
  1753.           then leading zeros will be supplied to fill up the field. If the
  1754.           field width starts with a '+' e.g. %+7d then a plus sign will be
  1755.           printed for positive values. 
  1756.  
  1757.  Example 1:   rate = 7.875
  1758.           printf(myfile, "The interest rate is: %8.2f\n", rate)
  1759.           
  1760.           The interest rate is:     7.88
  1761.  
  1762.  Example 2:   name="John Smith"
  1763.           score=97
  1764.           printf(1, "%15s, %5d\n", {name, score})
  1765.  
  1766.                John Smith,    97
  1767.                
  1768.  Comments:    Watch out for the following common mistake:
  1769.  
  1770.              printf(1, "%s", name)
  1771.  
  1772.           This will print only the first character of name, as each element 
  1773.           of name is taken to be a separate value to be formatted. You must 
  1774.           say this instead:
  1775.  
  1776.              printf(1, "%s", {name})
  1777.  
  1778.            Now, the third argument of printf is a one-element sequence
  1779.            containing a single value to be formatted.
  1780.  
  1781.  See Also:    sprintf, puts, open         
  1782.  
  1783. ─────────────────────────────────────<puts>─────────────────────────────────────
  1784.  
  1785.  Syntax:      puts(fn, x)
  1786.     
  1787.  Description: Output, to file or device fn, a single byte (atom) or sequence 
  1788.            of bytes. The low order 8-bits of each value is actually sent 
  1789.            out. If fn is the screen you will see text characters displayed.
  1790.  
  1791.  Comment:     When you output a sequence of bytes it must not have any 
  1792.            (sub)sequences within it. It must be a sequence of atoms only.
  1793.            (Typically a string of ASCII codes).
  1794.            
  1795.  Example 1:   puts(SCREEN, "Enter your first name: ")
  1796.  
  1797.  Example 2:   puts(output, 'A')  -- the single byte 65 will be sent to output  
  1798.  
  1799.  See Also:    printf, gets, open
  1800.  
  1801. ─────────────────────────────────────<rand>─────────────────────────────────────
  1802.  
  1803.  Syntax:      x2 = rand(x1) 
  1804.     
  1805.  Description: Return a random integer from 1 to x1, where x1 may be from 1 to 
  1806.           the largest positive value of type integer (1073741823).
  1807.  
  1808.  Comments:    This function may be applied to an atom or to all elements
  1809.            of a sequence.
  1810.  
  1811.  Example:     s = rand({10, 20, 30})
  1812.            -- s might be: {5, 17, 23} or {9, 3, 12} etc.
  1813.  
  1814.  See Also:    set_rand
  1815.  
  1816. ─────────────────────────────────<read_bitmap>──────────────────────────────────
  1817.  
  1818.  Syntax:      include image.e
  1819.            x = read_bitmap(st)
  1820.  
  1821.  Description: st is the name of a .bmp "bitmap" file. The file should be in
  1822.            the bitmap format. The most common variations of the format
  1823.            are supported. If the file is read successfully the result will
  1824.            be a 2-element sequence. The first element is the palette. The
  1825.            second element is a 2-d sequence of sequences containing a 
  1826.            graphics-mode image. You can pass the palette to all_palette() 
  1827.            (after dividing it by 4 to scale it). The image can be passed 
  1828.            to display_image().
  1829.           
  1830.           Bitmaps of 2,4,16 or 256 colors are supported. If the file is 
  1831.           not in a good format an error code (atom) is returned instead:
  1832.           
  1833.         global constant BMP_OPEN_FAILED = 1,
  1834.                 BMP_UNEXPECTED_EOF = 2,
  1835.                 BMP_UNSUPPORTED_FORMAT = 3
  1836.           
  1837.  Comments:    You can create your own bitmap picture files using Windows
  1838.            Paintbrush and many other graphics programs. You can then 
  1839.            incorporate these pictures into your Euphoria programs.
  1840.  
  1841.  Example:     x = read_bitmap("c:\\windows\\arcade.bmp")
  1842.            -- note: double backslash needed to get single backslash in
  1843.                       a string
  1844.  
  1845.  Example Program: demo\bitmap.ex
  1846.  
  1847.  See Also:    palette, display_image
  1848.  
  1849. ──────────────────────────────────<remainder>───────────────────────────────────
  1850.  
  1851.  Syntax:      x3 = remainder(x1, x2)
  1852.     
  1853.  Description: Compute the remainder after dividing x1 by x2. The result will 
  1854.            have the same sign as x1, and the magnitude of the result will
  1855.            be less than the magnitude of x2.
  1856.  
  1857.  Comments:    The arguments to this function may be atoms or sequences. The
  1858.            rules for arithmetic operations on sequences apply.
  1859.  
  1860.  Example 1:   a = remainder(9, 4)
  1861.            -- a is 1
  1862.            
  1863.  Example 2:   s = remainder({81, -3.5, -9, 5.5}, {8, -1.7, 2, -4})
  1864.           -- s is {1, -0.1, -1, 1.5}
  1865.  
  1866.  Example 3:   s = remainder({17, 12, 34}, 16)
  1867.            -- s is {1, 12, 2}
  1868.  
  1869.  Example 4:   s = remainder(16, {2, 3, 5})
  1870.            -- s is {0, 1, 1}
  1871.            
  1872. ────────────────────────────────────<repeat>────────────────────────────────────
  1873.  
  1874.  Syntax:      s = repeat(x, a)
  1875.     
  1876.  Description: Create a sequence of length a where each element is x.
  1877.     
  1878.  Comments:    When you repeat a sequence or a floating-point number the
  1879.            interpreter does not actually make multiple copies in memory.
  1880.            Rather, a single copy is "pointed to" a number of times. 
  1881.            
  1882.  Example 1:   repeat(0, 10)      -- {0,0,0,0,0,0,0,0,0,0}
  1883.         
  1884.  Example 2:   repeat("JOHN", 4)  -- {"JOHN", "JOHN", "JOHN", "JOHN"}
  1885.  
  1886.  See Also:    append, prepend, sequence-formation operator in refman.doc
  1887.  
  1888. ──────────────────────────────────<save_image>──────────────────────────────────
  1889.  
  1890.  Syntax:      include image.e
  1891.            s3 = save_image(s1, s2)
  1892.  
  1893.  Description: Save a rectangular image from a graphics screen. The result
  1894.            is a 2-d sequence of sequences containing all the pixels
  1895.            in the image. You can redisplay the image using display_image().
  1896.            s1 is a 2-element sequence {x1, y1} specifying the top-left 
  1897.            pixel in the image. s2 is a sequence {x2, y2} specifying the 
  1898.            bottom-right pixel.
  1899.  
  1900.  Comments:    You might use this in a graphical user interface to save a
  1901.            portion of the screen before you display a drop-down menu
  1902.            or dialog box.
  1903.            
  1904.  Example:     s = save_image({0,0}, {50,50})
  1905.            display_image({100,200}, s)
  1906.            display_image({300,400}, s)
  1907.            -- saves a 51x51 square image, then redisplays it at {100,200}
  1908.           -- and at {300,400}
  1909.  
  1910.  See Also:    display_image, save_text_image
  1911.  
  1912. ───────────────────────────────<save_text_image>────────────────────────────────
  1913.  
  1914.  Syntax:      include image.e
  1915.            s3 = save_text_image(s1, s2)
  1916.  
  1917.  Description: Save a rectangular region of text from a text-mode screen.
  1918.            The result is a sequence of sequences containing ASCII characters
  1919.            and attributes from the screen. You can redisplay this text using 
  1920.            display_text_image(). s1 is a 2-element sequence {line1, column1}
  1921.            specifying the top-left character. s2 is a sequence 
  1922.            {line2, column2} specifying the bottom right character.
  1923.            
  1924.  Comments:    Because the character attributes are also saved, you will get 
  1925.             the correct foreground and background color for each character
  1926.             if you redisplay the text.
  1927.             
  1928.           This routine only works in text modes.
  1929.           
  1930.            You might use this function in a text-mode graphical user 
  1931.            interface to save a portion of the screen before displaying a 
  1932.            drop-down menu, dialog box, alert box etc.
  1933.  
  1934.            If you are flipping video pages, note that this function reads
  1935.            from the current active page.
  1936.            
  1937.  Example:     If the top 2 lines of the screen have: 
  1938.           Hello 
  1939.           World
  1940.            
  1941.            s = save_text_image({1,1}, {2,5})
  1942.            
  1943.            Then s is something like: 
  1944.                    {"H-e-l-l-o-",
  1945.                          "W-o-r-l-d-"}
  1946.            where we have indicated the attribute bytes by '-'
  1947.                
  1948.  See Also:    display_text_image, save_image, set_active_page
  1949.  
  1950. ────────────────────────────────────<scroll>────────────────────────────────────
  1951.  
  1952.  Syntax:      include graphics.e 
  1953.            scroll(i1, i2, i3)
  1954.  
  1955.  Description: Scroll a region of text on the screen either up (i1 positive) or
  1956.             down (i1 negative) by i1 lines. The region is the series of lines
  1957.           on the screen from i2 (top line) to i3 (bottom line), inclusive.
  1958.           A    new blank line will appear at the top or bottom.
  1959.  
  1960.  Example Program: see bin\ed.ex
  1961.  
  1962.  See Also:    clear_screen, text_rows
  1963.  
  1964. ─────────────────────────────────────<seek>─────────────────────────────────────
  1965.  
  1966.  Syntax:      include file.e
  1967.            i1 = seek(fn, i2)
  1968.  
  1969.  Description: Seek (move) to any byte position in the file fn or to the end of
  1970.             file if i2 is -1. For each open file there is a current byte 
  1971.             position that is updated as a result of I/O operations on the 
  1972.             file. The initial file position is 0 for files opened for read,
  1973.             write or update. The initial position is the end of file for 
  1974.             files opened for append. The value returned by seek() is 0 if the
  1975.             seek was successful, and non-zero if it was unsuccessful. It is 
  1976.             possible to seek past the    end of a file. In this case undefined 
  1977.             bytes will be added to the file to make it long enough for the 
  1978.             seek.
  1979.  
  1980.  See Also:    where, open
  1981.      
  1982. ───────────────────────────────────<sequence>───────────────────────────────────
  1983.  
  1984.  Syntax:      i = sequence(x)
  1985.     
  1986.  Description: Return 1 if x is a sequence else return 0.
  1987.  
  1988.  Comments:    This serves to define the sequence type. You can also call
  1989.            it like an ordinary function to determine if an object is
  1990.            a sequence.
  1991.  
  1992.  Example 1:
  1993.            sequence s
  1994.            s = {1,2,3}
  1995.        
  1996.  Example 2:
  1997.            if sequence(x) then
  1998.                  sum = 0
  1999.                  for i = 1 to length(x) do
  2000.                      sum = sum + x[i]
  2001.                  end for
  2002.            else
  2003.                -- x must be an atom
  2004.                sum = x     
  2005.            end if
  2006.  
  2007.  See Also:    atom, object type in refman.doc
  2008.  
  2009. ───────────────────────────────<set_active_page>────────────────────────────────
  2010.            
  2011.  Syntax:      include image.e
  2012.            set_active_page(i)
  2013.            
  2014.  Description: Select video page i to send all screen output to.           
  2015.  
  2016.  Comments:    With multiple pages you can instantaneously change the entire
  2017.            screen without causing any visible "flicker". You can also
  2018.            save the screen and bring it back quickly.
  2019.  
  2020.           video_config() will tell you how many pages are available in
  2021.           the current graphics mode.
  2022.  
  2023.            By default, the active page and the display page are both 0.
  2024.            
  2025.            This works under DOS, or full-screen under Windows. In a 
  2026.            partial-screen window you cannot change the active page.
  2027.            
  2028.  Example:     include image.e
  2029.            
  2030.            -- active & display pages are initially both 0
  2031.            puts(1, "\nThis is page 0\n")
  2032.            set_active_page(1)     -- screen output will now go to page 1
  2033.            clear_screen()
  2034.            puts(1, "\nNow we've flipped to page 1\n")
  2035.            if getc(0) then        -- wait for key-press
  2036.            end if
  2037.            set_display_page(1)    -- "Now we've ..." becomes visible
  2038.            if getc(0) then        -- wait for key-press
  2039.            end if
  2040.           set_display_page(0)    -- "This is ..." becomes visible again
  2041.           set_active_page(0)
  2042.  
  2043.  See Also:    get_active_page, set_display_page 
  2044.  
  2045. ──────────────────────────────<set_display_page>────────────────────────────────
  2046.            
  2047.  Syntax:      include image.e
  2048.            set_display_page(i)
  2049.  
  2050.  Description: Set video page i to be mapped to the visible screen.
  2051.  
  2052.  Comments:    With multiple pages you can instantaneously change the entire
  2053.            screen without causing any visible "flicker". You can also
  2054.            save the screen and bring it back quickly.
  2055.  
  2056.           video_config() will tell you how many pages are available in
  2057.           the current graphics mode.
  2058.  
  2059.            By default, the active page and the display page are both 0.
  2060.            
  2061.            This works under DOS, or full-screen under Windows. In a 
  2062.            partial-screen window you cannot change the active page.
  2063.            
  2064.  Example:     See set_active_page example.
  2065.  
  2066.  See Also:    get_display_page, set_active_page
  2067.            
  2068. ──────────────────────────────────<set_rand>────────────────────────────────────
  2069.  
  2070.  Syntax:      include machine.e
  2071.            set_rand(i)
  2072.  
  2073.  Description: Set the random number generator to a certain state, i, so that
  2074.            you will get a known series of random numbers on subsequent
  2075.            calls to rand().
  2076.  
  2077.  Comments:    Normally the numbers returned by the rand() function are totally
  2078.             unpredictable, and will be different each time you run your
  2079.             program. Sometimes however you may wish to repeat the same
  2080.             series of numbers, perhaps because you are trying to debug
  2081.             your program, or maybe you want the ability to generate the
  2082.             same output (e.g. a random picture) for your user upon request. 
  2083.  
  2084.  Example:     sequence s, t
  2085.            s = repeat(0, 3)
  2086.            t = s
  2087.            
  2088.            set_rand(12345)
  2089.            s[1] = rand(10)
  2090.            s[2] = rand(100)
  2091.            s[3] = rand(1000)
  2092.            
  2093.            set_rand(12345)  -- same value for set_rand()
  2094.            t[1] = rand(10)  -- same arguments to rand() as before
  2095.            t[2] = rand(100)
  2096.            t[3] = rand(1000)
  2097.            -- at this point s and t will be identical
  2098.  
  2099.  See Also:    rand
  2100.  
  2101. ─────────────────────────────────────<sin>──────────────────────────────────────
  2102.  
  2103.  Syntax:      x2 = sin(x1)
  2104.     
  2105.  Description: Return the sine of x1, where x1 is in radians.
  2106.  
  2107.  Comments:    This function may be applied to an atom or to all elements
  2108.            of a sequence.
  2109.  
  2110.  Example:     sin_x = sin({.5, .9, .11})
  2111.            -- sin_x is {.479, .783, .110} 
  2112.  
  2113.  See Also:    cos, tan
  2114.  
  2115. ─────────────────────────────────────<sort>─────────────────────────────────────
  2116.  
  2117.  Syntax:      include sort.e
  2118.            s2 = sort(s1)
  2119.     
  2120.  Description: Sort s1 into ascending order using a fast sorting algorithm. The
  2121.             elements of s1 can be any mix of atoms or sequences. Atoms come 
  2122.             before sequences, and sequences are sorted "alphabetically" where
  2123.             the first elements are more significant than the later elements.
  2124.  
  2125.  Comments:    By defining your own compare function to override the built-in 
  2126.           compare(), you can change the ordering of values from sort(), and 
  2127.           perhaps choose a field or element number on which to base the 
  2128.           sort. Define your compare() as a global function before 
  2129.           including sort.e.
  2130.  
  2131.  Example 1:   x = 0 & sort({7,5,3,8}) & 0
  2132.           -- x is set to {0, 3, 5, 7, 8, 0}
  2133.  
  2134.  Example 2:   y = sort({"Smith", "Jones", "Doe", 5.5, 4, 6})
  2135.            -- y is {4, 5.5, 6, "Doe", "Jones", "Smith"}
  2136.            
  2137.  Example 3:   database = sort({{"Smith",   95.0, 29},
  2138.                           {"Jones",   77.2, 31},
  2139.                           {"Clinton", 88.7, 44}})
  2140.           
  2141.           -- The 3 database "records" will be sorted by the first "field"
  2142.           -- i.e. by name. Where the first field (element) is equal it 
  2143.           -- will be sorted by the second field etc.
  2144.           
  2145.           -- database is {{"Clinton", 88.7, 44},
  2146.                         {"Jones",   77.2, 31},
  2147.                         {"Smith",   95.0, 29}}
  2148.  
  2149.  See Also:    compare, match, find
  2150.   
  2151. ────────────────────────────────────<sound>─────────────────────────────────────
  2152.  
  2153.  Syntax:      sound(i)
  2154.     
  2155.  Description: Turn on the PC speaker at frequency i. If i is 0 the speaker 
  2156.            will be turned off.
  2157.  
  2158.  Example:     sound(1000) -- starts a fairly high pitched sound
  2159.  
  2160. ───────────────────────────────────<sprintf>────────────────────────────────────
  2161.  
  2162.  Syntax:      s = sprintf(st, x)
  2163.  
  2164.  Description: This is exactly the same as printf(), except that the output
  2165.            is returned as a sequence of characters, rather than being
  2166.            sent to a file or device. st is a format string, x is the
  2167.            value or sequence of values to be formatted. printf(fn, st, x) 
  2168.            is equivalent to puts(fn, sprintf(st, x)).
  2169.  
  2170.  Comments:    Some typical uses of sprintf are:
  2171.                 
  2172.                 1. Converting numbers to strings.
  2173.                 2. Creating strings to pass to system().
  2174.                 3. Creating formatted error messages and passing them to
  2175.                    a common error message handler.
  2176.  
  2177.  Example:     s = sprintf("%08d", 12345)
  2178.             -- s is "00012345"
  2179.             
  2180.  See Also:    printf, value, get
  2181.  
  2182. ─────────────────────────────────────<sqrt>─────────────────────────────────────
  2183.  
  2184.  Syntax:      x2 = sqrt(x1)   
  2185.     
  2186.  Description: Calculate the square root of x1.
  2187.  
  2188.  Comments:    This function may be applied to an atom or to all elements
  2189.            of a sequence.
  2190.  
  2191.            Taking the square root of a negative number will abort your
  2192.            program with a run-time error message.
  2193.            
  2194.  Example:     r = sqrt(16)
  2195.            -- r is 4
  2196.  
  2197.  See Also:    log, power
  2198.  
  2199. ────────────────────────────────────<system>────────────────────────────────────
  2200.  
  2201.  Syntax:      system(s, a)
  2202.     
  2203.  Description: Pass a command string s to the DOS command interpreter for 
  2204.            execution. The argument a indicates the manner in which to 
  2205.           return from the system call. 
  2206.         
  2207.         value of a      return action
  2208.         ----------    ------------- 
  2209.              0      - restore previous graphics mode
  2210.                   (clears the screen)
  2211.              1      - make a beep sound, wait for a
  2212.                   key press, then restore the
  2213.                   graphics mode
  2214.              2      - do not restore graphics mode
  2215.  
  2216.  Comments:    Action 2 should only be used when it is known that the system 
  2217.            call will not change the graphics mode. 
  2218.  
  2219.           You can use Euphoria as a sophisticated DOS "batch" language
  2220.           by making calls to system().
  2221.           
  2222.            A Euphoria program will start off using extended memory. If 
  2223.            extended memory runs out the program will consume conventional 
  2224.            memory. If conventional memory runs out it will use virtual 
  2225.            memory, i.e. swap space on disk. The DOS command run by system()
  2226.            will fail if there is not enough conventional memory available. 
  2227.            To avoid this situation you can reserve some conventional (low) 
  2228.            memory by typing:
  2229.                     
  2230.                     SET CAUSEWAY=LOWMEM:xxx
  2231.            
  2232.            where xxx is the number of K of conventional memory to reserve.
  2233.            Type this before running your program. You can also put this in 
  2234.            a .bat file that runs your program, or in AUTOEXEC.BAT. For
  2235.            example:
  2236.                     
  2237.                     SET CAUSEWAY=LOWMEM:80
  2238.                     ex myprog.ex
  2239.            
  2240.            This will reserve 80K of conventional memory, which should be
  2241.            enough to run simple DOS commands like COPY, MOVE, MKDIR etc.
  2242.            
  2243.  Example:     system("copy temp.txt a:\\temp.bak", 2)
  2244.            -- note use of double backslash in literal string to get 
  2245.               single backslash
  2246.  
  2247.  Example Program: see install.ex
  2248.  
  2249.  See Also:    dir, current_dir, getenv, command_line
  2250.  
  2251. ─────────────────────────────────────<tan>──────────────────────────────────────
  2252.  
  2253.  Syntax:      x2 = tan(x1) 
  2254.     
  2255.  Description: Return the tangent of x1, where x1 is in radians.
  2256.  
  2257.  Comments:    This function may be applied to an atom or to all elements
  2258.            of a sequence.
  2259.  
  2260.  Example:     t = tan(1.0)
  2261.            -- t is 1.55741
  2262.          
  2263.  See Also:    sin, cos
  2264.  
  2265. ──────────────────────────────────<text_color>──────────────────────────────────
  2266.  
  2267.  Syntax:      include graphics.e
  2268.            text_color(i)
  2269.     
  2270.  Description: Set the foreground text color. Add 16 to get blinking text
  2271.           in some modes. See graphics.e for a list of possible colors.
  2272.  
  2273.  Comments:    Text that you print *after* calling text_color will have the
  2274.            desired color. 
  2275.            
  2276.            When your program terminates, the last color that you selected
  2277.            and actually printed on the screen will remain in effect.
  2278.            Thus you may have to print something, maybe just '\n', in 
  2279.            WHITE to restore white text, especially if you are at the 
  2280.            bottom line of the screen, ready to scroll up.
  2281.            
  2282.  Example:     text_color(BRIGHT_BLUE)
  2283.  
  2284.  See Also:    bk_color
  2285.  
  2286. ──────────────────────────────────<text_rows>───────────────────────────────────
  2287.  
  2288.  Syntax:      include graphics.e
  2289.            i2 = text_rows(i1)
  2290.     
  2291.  Description: Set the number of lines of text on the screen to i1 if possible.
  2292.           i2 will be set to the actual new number of lines.
  2293.  
  2294.  Comments:    Values of 25, 28, 43 and 50 lines are supported by most graphics
  2295.            cards.
  2296.            
  2297.  See Also:    graphics_mode
  2298.  
  2299. ─────────────────────────────────────<time>─────────────────────────────────────
  2300.  
  2301.  Syntax:      a = time()
  2302.     
  2303.  Description: Return the number of seconds since some fixed point in the past.
  2304.             The resolution on MS-DOS is about 0.05 seconds. 
  2305.  
  2306.  Comments:    Take the difference between two readings of time(), to
  2307.            measure, for example, how long a section of code takes to
  2308.            execute.
  2309.  
  2310.  Example:     constant ITERATIONS = 1000000 
  2311.            integer p
  2312.            atom t0, loop_overhead
  2313.            
  2314.            t0 = time()
  2315.            for i = 1 to ITERATIONS do
  2316.            end for
  2317.            loop_overhead = time() - t0
  2318.      
  2319.           t0 = time()
  2320.            for i = 1 to ITERATIONS do
  2321.                  p = power(2, 20)
  2322.            end for
  2323.            ? (time() - t0 - loop_overhead)/ITERATIONS
  2324.            -- calculates time (in seconds) for one call to power
  2325.            
  2326.  See Also:    date
  2327.  
  2328. ────────────────────────────────────<trace>─────────────────────────────────────
  2329.  
  2330.  Syntax:      with trace
  2331.            trace(x) 
  2332.     
  2333.  Description: If x is 1 or 2 then turn on full-screen statement tracing. If x 
  2334.            is 0 then    turn off tracing. When x is 2 a monochrome trace 
  2335.            display is forced on. Tracing only occurs in subroutines that 
  2336.            were compiled when "with trace" was in effect. See the section 
  2337.            on Debugging in refman.doc.
  2338.  
  2339.  Comments:    Use trace(2) if the color display is hard to view on your system.
  2340.  
  2341.  Example:     if x < 0 then
  2342.            -- ok, here's the case I want to debug...
  2343.            trace(1)
  2344.            -- etc.
  2345.           ...
  2346.           end if           
  2347.                
  2348.  See Also:    Chapter 3 in refman.doc.
  2349.  
  2350. ────────────────────────────────────<upper>─────────────────────────────────────
  2351.  
  2352.  Syntax:      include wildcard.e
  2353.            s2 = upper(s1)
  2354.  
  2355.  Description: Convert a string of characters to upper case.
  2356.  
  2357.  Example:     s = upper("Euphoria")
  2358.            -- s is "EUPHORIA"
  2359.            
  2360.  See Also:    lower
  2361.  
  2362. ──────────────────────────────────<use_vesa>────────────────────────────────────
  2363.  
  2364.  Syntax:      include machine.e
  2365.            use_vesa(i)
  2366.            
  2367.  Description: use_vesa(1) will force Euphoria to use the VESA graphics
  2368.            standard. This may cause Euphoria programs to work better
  2369.            in SVGA graphics modes with certain graphics cards.
  2370.            use_vesa(0) will restore Euphoria's original method of
  2371.            using the graphics card.
  2372.            
  2373.  Comments:    Most people can ignore this. However if you experience
  2374.            difficulty in SVGA graphics modes you should try calling
  2375.            use_vesa(1) at the start of your program before any calls
  2376.            to graphics_mode().
  2377.  
  2378.            Arguments to use_vesa() other than 0 or 1 should not be used.
  2379.            
  2380.  Example:     use_vesa(1)
  2381.            fail = graphics_mode(261)
  2382.            
  2383.  See Also:    graphics_mode
  2384.  
  2385. ────────────────────────────────────<value>─────────────────────────────────────
  2386.  
  2387.  Syntax:      include get.e
  2388.            s = value(st)
  2389.  
  2390.  Description: Read the string representation of a Euphoria object, and compute
  2391.            the value of that object. A 2-element sequence, 
  2392.            {error_status, value} is actually returned, where error_status
  2393.            can be one of:
  2394.         
  2395.         GET_SUCCESS     -- a valid object representation was found
  2396.         GET_EOF        -- end of string reached too soon
  2397.         GET_FAIL    -- syntax is wrong 
  2398.                
  2399.  Comments:    This works the same as get(), but it reads from a string
  2400.            that you supply, rather than from a file or device.
  2401.            
  2402.  Example 1:   s = value("12345"}
  2403.            -- s is {GET_SUCCESS, 12345}
  2404.            
  2405.  Example 2:   s = value("{0, 1, -99.9}")
  2406.            -- s is {GET_SUCCESS, {0, 1, -99.9}}
  2407.            
  2408.  Example 3:   s = value("+++")
  2409.            -- s is {GET_FAIL, 0}
  2410.  
  2411.  See Also:    get, sprintf, print
  2412.  
  2413. ─────────────────────────────────<video_config>─────────────────────────────────
  2414.  
  2415.  Syntax:      include graphics.e
  2416.            s = video_config()
  2417.     
  2418.  Description: Return a sequence of values describing the current video
  2419.           configuration:
  2420.         {color monitor?, graphics mode, text rows, text columns,
  2421.          xpixels, ypixels, number of colors, number of pages}
  2422.            
  2423.            The following constants are defined in graphics.e:
  2424.             
  2425.             global constant VC_COLOR = 1,
  2426.                 VC_MODE  = 2,
  2427.                 VC_LINES = 3,
  2428.                 VC_COLUMNS = 4,
  2429.                 VC_XPIXELS = 5,
  2430.                 VC_YPIXELS = 6,
  2431.                 VC_NCOLORS = 7,
  2432.                 VC_PAGES = 8
  2433.            
  2434.  Comments:    This routine makes it easy for you to parameterize a program 
  2435.            so it will work in many different graphics modes.
  2436.            
  2437.            On the PC there are two types of graphics mode. The first type
  2438.            lets you print text only. The second type lets you plot pixels,
  2439.            or points, in various colors. The second type also usually lets
  2440.            you print text. You can tell that you are in a purely text mode,
  2441.            because the VC_XPIXELS and VC_YPIXELS fields will be 0. 
  2442.            Library routines such as polygon, draw_line, and ellipse only
  2443.            work in a pixel mode.
  2444.            
  2445.  Example:     vc = video_config()  -- in mode 3 with 25-lines of text:
  2446.            -- vc is {1, 3, 25, 80, 0, 0, 32, 8}
  2447.  
  2448.  See Also:    graphics_mode
  2449.  
  2450. ──────────────────────────────────<wait_key>────────────────────────────────────
  2451.  
  2452.  Syntax:      include get.e
  2453.            i = wait_key()
  2454.            
  2455.  Description: Return the next key pressed by the user. Don't return until
  2456.             a key is pressed.
  2457.             
  2458.  Comments:    You could achieve the same result using get_key() as follows:
  2459.                 
  2460.                 while 1 do
  2461.                     k = get_key()
  2462.                     if k != -1 then
  2463.                         exit
  2464.                     end if
  2465.                 end while    
  2466.  
  2467.            However, on multi-tasking systems like Windows, Windows NT,
  2468.            or OS/2 this "busy waiting" would slow the system down. 
  2469.            wait_key() lets the operating system do other useful work 
  2470.            while your program is waiting for the user to press a key.
  2471.  
  2472.            You could also use getc(0), assuming file number 0 was input 
  2473.            from the keyboard, except that you wouldn't pick up the special
  2474.            codes for function keys, arrow keys etc.
  2475.            
  2476.  See Also:    get_key, getc
  2477.  
  2478. ────────────────────────────────────<where>─────────────────────────────────────
  2479.  
  2480.  Syntax:      include file.e
  2481.            i = where(fn)
  2482.     
  2483.  Description: This function returns the current byte position in the file fn.
  2484.           This position is updated by reads, writes and seeks on the file.
  2485.           It is the place in the file where the next byte will be read 
  2486.           from, or written to.
  2487.  
  2488.  See Also:    seek, open
  2489.  
  2490. ────────────────────────────────<wildcard_file>─────────────────────────────────
  2491.  
  2492.  Syntax:      include wildcard.e
  2493.            i = wildcard_file(s1, s2)
  2494.  
  2495.  Description: Return 1 (TRUE) if the filename s2 matches the wild card pattern
  2496.            s1. Return 0 (FALSE) otherwise. This is similar to DOS wildcard
  2497.            matching, but better in some cases. * matches any 0 or more 
  2498.            characters, ? matches any single character. Character comparisons
  2499.            are not case sensitive. 
  2500.  
  2501.  Comments:    You might use this function to check the output of the dir()
  2502.            routine for file names that match a pattern supplied by the 
  2503.            user of your program.
  2504.  
  2505.            In DOS "*ABC.*" will match ALL files. wildcard_file("*ABC.*", s)
  2506.            will only match when the file name part has "ABC" at the end
  2507.            (as you would expect).
  2508.  
  2509.  Example 1:   i = wildcard_file("AB*CD.?", "aB123cD.e")  
  2510.           -- i is set to 1
  2511.           
  2512.  Example 2:   i = wildcard_file("AB*CD.?", "abcd.ex")
  2513.            -- i is set to 0, because the file type has 2 letters not 1
  2514.            
  2515.  Example Program: see bin\search.ex
  2516.  
  2517.  See Also:    wildcard_match, dir
  2518.  
  2519. ────────────────────────────────<wildcard_match>────────────────────────────────
  2520.  
  2521.  Syntax:      include wildcard.e
  2522.            i = wildcard_match(s1, s2)
  2523.  
  2524.  Description: This function performs general matching of a string against a 
  2525.            pattern containing * and ? wildcards. It returns 1 (TRUE) if 
  2526.            string s2 matches pattern s1. It returns 0 (FALSE) otherwise. 
  2527.            * matches any 0 or more characters. ? matches any
  2528.            single character. Character comparisons are case sensitive.
  2529.  
  2530.  Comments:    If you want case insensitive comparisons, pass both s1 and s2
  2531.            through upper(), or both through lower() before calling
  2532.            wildcard_match().
  2533.  
  2534.            If you want to detect a pattern anywhere within a string,
  2535.            add * to each end of the pattern:
  2536.              
  2537.              i = wildcard_match('*' & pattern & '*', string)
  2538.  
  2539.            There is currently no way to treat * or ? literally in a pattern.
  2540.            
  2541.  Example 1:   i = wildcard_match("A?B*", "AQBXXYY")          
  2542.            -- i is 1 (TRUE)
  2543.            
  2544.  Example 2:   i = wildcard_match("*xyz*", "AAAbbbxyz")
  2545.            -- i is 1 (TRUE)
  2546.  
  2547.  Example 3:   i = wildcard_match("A*B*C", "a111b222c")
  2548.            -- i is 0 (FALSE) because upper/lower case doesn't match
  2549.  
  2550.  Example Program: see bin\search.ex
  2551.  
  2552.  See Also:    wildcard_file, match, upper, lower, compare
  2553.  
  2554. ─────────────────────────────────────<wrap>─────────────────────────────────────
  2555.  
  2556.  Syntax:      include graphics.e
  2557.            wrap(i)
  2558.     
  2559.  Description: Allow text to wrap at the right margin (i = 1) or get truncated
  2560.             (i = 0).
  2561.  
  2562.  Comments:    By default text will wrap.
  2563.  
  2564.  Example:     puts(1, repeat('x', 100) & "\n\n") 
  2565.            -- now have a line of 80 'x' followed a line of 20 more 'x'
  2566.            wrap(0)
  2567.            puts(1, repeat('x', 100) & "\n\n")
  2568.            -- creates just one line of 80 'x' 
  2569.            
  2570.  See Also:    puts, position
  2571.  
  2572.